Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/ExpressionLanguageProvider.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\DependencyInjection; | |
13 | |
14 use Symfony\Component\ExpressionLanguage\ExpressionFunction; | |
15 use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; | |
16 | |
17 /** | |
18 * Define some ExpressionLanguage functions. | |
19 * | |
20 * To get a service, use service('request'). | |
21 * To get a parameter, use parameter('kernel.debug'). | |
22 * | |
23 * @author Fabien Potencier <fabien@symfony.com> | |
24 */ | |
25 class ExpressionLanguageProvider implements ExpressionFunctionProviderInterface | |
26 { | |
27 public function getFunctions() | |
28 { | |
29 return array( | |
30 new ExpressionFunction('service', function ($arg) { | |
31 return sprintf('$this->get(%s)', $arg); | |
32 }, function (array $variables, $value) { | |
33 return $variables['container']->get($value); | |
34 }), | |
35 | |
36 new ExpressionFunction('parameter', function ($arg) { | |
37 return sprintf('$this->getParameter(%s)', $arg); | |
38 }, function (array $variables, $value) { | |
39 return $variables['container']->getParameter($value); | |
40 }), | |
41 ); | |
42 } | |
43 } |