liuggio / StatsDClientBundle

Easily monitor your symfony2 production env., with ready-to-use stats.
MIT License
164 stars 43 forks source link

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

Open artem-frolov opened 10 years ago

artem-frolov commented 10 years ago

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');
    }
}
liuggio commented 10 years ago

Yes I think it makes sense, would you like to work on this fix?