Skip to content

Commit

Permalink
Unify the way to provide expression functions for the DI container
Browse files Browse the repository at this point in the history
Function providers registered on the ContainerBuilder are now reused by
the PhpDumper when dumping the container instead of forcing to register
them again.
Closes #13012
  • Loading branch information
stof committed Dec 17, 2014
1 parent c18cb4c commit 8425e4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -1075,6 +1075,14 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
$this->expressionLanguageProviders[] = $provider;
}

/**
* @return ExpressionFunctionProviderInterface[]
*/
public function getExpressionLanguageProviders()
{
return $this->expressionLanguageProviders;
}

/**
* Returns the Service Conditionals.
*
Expand Down
Expand Up @@ -1399,6 +1399,11 @@ public function dumpParameter($name)
return sprintf("\$this->getParameter('%s')", strtolower($name));
}

/**
* @deprecated Deprecated since 2.6.2, to be removed in 3.0. Use Symfony\Component\DependencyInjection\ContainerBuilder::addExpressionLanguageProvider instead.
*
* @param ExpressionFunctionProviderInterface $provider
*/
public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider)
{
$this->expressionLanguageProviders[] = $provider;
Expand Down Expand Up @@ -1493,7 +1498,8 @@ private function getExpressionLanguage()
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
}
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);
$providers = array_merge($this->container->getExpressionLanguageProviders(), $this->expressionLanguageProviders);
$this->expressionLanguage = new ExpressionLanguage(null, $providers);
}

return $this->expressionLanguage;
Expand Down

0 comments on commit 8425e4d

Please sign in to comment.