4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection;
14 use Symfony\Component\ExpressionLanguage\ExpressionFunction;
15 use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
18 * Define some ExpressionLanguage functions.
20 * To get a service, use service('request').
21 * To get a parameter, use parameter('kernel.debug').
23 * @author Fabien Potencier <fabien@symfony.com>
25 class ExpressionLanguageProvider implements ExpressionFunctionProviderInterface
27 public function getFunctions()
30 new ExpressionFunction('service', function ($arg) {
31 return sprintf('$this->get(%s)', $arg);
32 }, function (array $variables, $value) {
33 return $variables['container']->get($value);
36 new ExpressionFunction('parameter', function ($arg) {
37 return sprintf('$this->getParameter(%s)', $arg);
38 }, function (array $variables, $value) {
39 return $variables['container']->getParameter($value);