mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/11103] Use scope: prototype
This lets us clean up the mess that was in load_object(), but requires scope: prototype to be added to the service definitions for all types or methods! PHPBB3-11103
This commit is contained in:
@@ -779,24 +779,6 @@ class phpbb_notification_manager
|
||||
*/
|
||||
protected function load_object($object_name)
|
||||
{
|
||||
// Here we cannot just use ContainerBuilder->get(name)
|
||||
// The reason for this is because get handles services
|
||||
// which are initialized once and shared. Here we need
|
||||
// separate new objects because we pass around objects
|
||||
// that store row data in each object, which would lead
|
||||
// to over-writing of data if we used get()
|
||||
|
||||
$parameterBag = $this->phpbb_container->getParameterBag();
|
||||
$definition = $this->phpbb_container->getDefinition($object_name);
|
||||
$arguments = $this->phpbb_container->resolveServices(
|
||||
$parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments()))
|
||||
);
|
||||
$r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass()));
|
||||
|
||||
$object = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments);
|
||||
|
||||
$object->set_notification_manager($this);
|
||||
|
||||
return $object;
|
||||
return $this->phpbb_container->get($object_name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user