[DependencyInjection] simplify the BC layer

The change to the `setFactoryService()` method is consistent with what
we did with the `getFactoryService()` before (and how we handle the
deprecation of strict references in Symfony 2.8).
This commit is contained in:
Christian Flothmann 2016-01-27 12:46:36 +01:00
parent 3a027badb7
commit 6cd5ee3b26
3 changed files with 6 additions and 7 deletions

View File

@ -44,10 +44,7 @@ class ResolveReferencesToAliasesPass implements CompilerPassInterface
$definition->setMethodCalls($this->processArguments($definition->getMethodCalls()));
$definition->setProperties($this->processArguments($definition->getProperties()));
$definition->setFactory($this->processFactory($definition->getFactory()));
if (null !== $factoryService = $definition->getFactoryService(false)) {
$definition->setFactoryService($this->processFactoryService($factoryService));
}
$definition->setFactoryService($this->processFactoryService($definition->getFactoryService(false)), false);
}
foreach ($container->getAliases() as $id => $alias) {

View File

@ -194,9 +194,11 @@ class Definition
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryService($factoryService)
public function setFactoryService($factoryService, $triggerDeprecationError = true)
{
@trigger_error(sprintf('%s(%s) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryService), E_USER_DEPRECATED);
if ($triggerDeprecationError) {
@trigger_error(sprintf('%s(%s) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryService), E_USER_DEPRECATED);
}
$this->factoryService = $factoryService;

View File

@ -99,7 +99,7 @@ class DefinitionDecorator extends Definition
/**
* {@inheritdoc}
*/
public function setFactoryService($service)
public function setFactoryService($service, $triggerDeprecationError = true)
{
$this->changes['factory_service'] = true;