I want to add an extra bag to symfony session.
I do that in compiler pass:
public function process(ContainerBuilder $container)
{
$bag = new AttributeBag("my_session_attributes");
$container->getDefinition("session")
->addMethodCall("registerBag", [$bag]);
}
But i get an exception with message:
Unable to dump a service container if a parameter is an object or a resource.
Here is the trace stack:
- in XmlDumper.php line 379
- at XmlDumper::phpToXml(object(AttributeBag)) in XmlDumper.php line 328
- at XmlDumper->convertParameters(array(object(AttributeBag)), 'argument', object(DOMElement)) in XmlDumper.php line 94
- at XmlDumper->addMethodCalls(array(array('registerBag', array(object(AttributeBag)))), object(DOMElement)) in XmlDumper.php line 183
- at XmlDumper->addService(object(Definition), 'session', object(DOMElement)) in XmlDumper.php line 272
- at XmlDumper->addServices(object(DOMElement)) in XmlDumper.php line 52
- at XmlDumper->dump() in ContainerBuilderDebugDumpPass.php line 34
- at ContainerBuilderDebugDumpPass->process(object(ContainerBuilder)) in Compiler.php line 104
- at Compiler->compile(object(ContainerBuilder)) in ContainerBuilder.php line 598
- at ContainerBuilder->compile() in Kernel.php line 514
- at Kernel->initializeContainer() in Kernel.php line 133
- at Kernel->boot() in Kernel.php line 182
- at Kernel->handle(object(Request)) in app_dev.php line 29
How should I add new bag if I can't pass object arguments in service definitions?