Closed
Description
So when updating from SF 2.6.1 to 2.6.6 i found my self stuck with a error on cache:clear
.
After some research I found out that in one of our internal components we where doing the following:
$container
# ...
->setFactoryService(new Reference($entityManagerService));
This used to work but due to a change made in #13519 if stopped working.
The code dumped after #13519 was merged looks something like (see the double $this->get
):
return $this->services['service_name'] = new \SomeLoader($this->get($this->get('object_manager'))->getRepository('EntityClass'));
I'm not sure if this a BC break everyone is ok with but it confused the ..... out of me.
A simple fix would be to modify the code in src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
around line 1334.
-$service = $this->dumpValue($value->getFactoryService());
-
-return sprintf('%s->%s(%s)', 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments));
+$service = null;
+if (!$value->getFactoryService() instanceof Reference) {
+ $service = $this->dumpValue($value->getFactoryService());
+ $service = (0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : null);
+}
+$service = $service ?: $this->getServiceCall($value->getFactoryService());
+
+return sprintf('%s->%s(%s)', $service, $value->getFactoryMethod(), implode(', ', $arguments));
Is there any interest in a PR for this?
Metadata
Metadata
Assignees
Labels
No labels