Skip to content

User collector stops application if security.context service is not defined #41

@artem-frolov

Description

@artem-frolov

I work on the application where the security.context service doesn't exist because there is no Symfony authorization in the app.

When enable_collector is true the app doesn't work because of unsatisfied security.context dependency for the liuggio_stats_d_client.collector.user service.

StatsDClientBundle shouldn't require security.context service when the user collector is not used.

For now I use the following workaround:

class MyBundle extends Bundle
{
    /**
     * {@inheritDoc}
     */
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $container->addCompilerPass(new StatsdUserCollectorCompilerPass());
    }
}

class StatsdUserCollectorCompilerPass implements CompilerPassInterface
{
    /**
     * {@inheritDoc}
     */
    public function process(ContainerBuilder $container)
    {
        $definition = $container->getDefinition('liuggio_stats_d_client.collector.user');
        $definition->removeMethodCall('setSecurityContext');
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions