symfony - Circular reference detected for service "security.context" -


i tried inject templating service , get.

<service id="myproject_notification.service.mail" class="%myproject_notification.service.mail.class%">     <argument type="service" id="mailer" />     <argument type="service" id="templating" /> </service> 

2014-06-10 12-37-10

if comment, or remove, templating service dependency, working well. saw old issues that, seems i'm 1 @ moment experiencing this. doing wrong?

composer.json

"symfony/symfony": "~2.4", "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", "sensio/distribution-bundle": "~2.3", "sensio/framework-extra-bundle": "~3.0", "sensio/generator-bundle": "~2.3", "incenteev/composer-parameter-handler": "~2.0", 

composer.lock

"name": "symfony/symfony", "version": "v2.5.0", ... "name": "twig/twig", "version": "v1.15.1", 

this solution quick way fix problem. can avoided, please read comments.

for particular case may best inject servicecontainer service. seems experiencing edge case, security.context injected templating services (e.g. helpers), in example injected (indirectly) security.context.

try this:

<service id="myproject_notification.service.mail" class="%myproject_notification.service.mail.class%">     <argument type="service" id="service_container" /> </service> 

and in class's constructor, use follows:

class yourmailerclass {     protected $container;      public function __construct(containerinterface $container )    {      $this->container = $container;      }       public function sendmail()     {        $mailer = $this->container->get('mailer');        $templating = $this->container->get('templating');     }  } 

see conversation between symfony core developers same problem: https://github.com/symfony/symfony/issues/2347

for cases injecting service container not advised several reasons.


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -