io sono sempre sotto l'errore,Errore: non è possibile creare un servizio ("templating.helper.assets") di un ambito inattiva ("richiesta")
[Twig_Error_Runtime]
An exception has been thrown during the rendering of a template ("You cannot create a service ("templating.helper.assets") of an inactive scope ("request").") in "AcmeMessagingBundle:Comment:email.html.twig".
sto il rendering modello ramoscello da symfony 2 personalizzato comando da console
Qui di seguito è la mia classe di servizio, che è l'abbonato evento, sto innescando eventi onCommentAddEmail dal comando della console symfony per inviare e-mail,
class NotificationSubscriber implements EventSubscriberInterface
{
private $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public static function getSubscribedEvents()
{
return array(
'comment.add' => array('onCommentAddEmail', 0),
);
}
public function onCommentAddEmail(CommentAddEvent $event)
{
...................
$body = $this->container->get('templating')->render(
'AcmeMessagingBundle:Comment:email.html.twig',
array('template' => $template)
);
.......
}
}
$ corpo è passato a Swiftmailer per inviare un'email.
Questo è il mio servizio di defination,
Acme \ MessagingBundle \ Subscriber \ NotificationSubscriber
<services>
<service id="notification_subscriber" class="%notification_subscriber.class%">
<argument type="service" id="service_container" />
<tag name="kernel.event_subscriber" />
</service>
</services>
Sotto messaggio dice che il problema è stato risolto in symfony 2.1, ma sono ancora errori ottenendo,
https://github.com/symfony/symfony/issues/4514
Ho già arbitrato a http://symfony.com/doc/current/cookbook/service_container/scopes.html, ho passato l'intero contenitore al mio servizio.
Dai un'occhiata alla risposta per un problema simile (http://stackoverflow.com/a/24409012/1263890) –