You are here

class ExpressionLanguageProvider in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ExpressionLanguageProvider.php \Symfony\Component\DependencyInjection\ExpressionLanguageProvider

Define some ExpressionLanguage functions.

To get a service, use service('request'). To get a parameter, use parameter('kernel.debug').

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

  • class \Symfony\Component\DependencyInjection\ExpressionLanguageProvider implements \Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface

Expanded class hierarchy of ExpressionLanguageProvider

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ExpressionLanguageProvider.php, line 25

Namespace

Symfony\Component\DependencyInjection
View source
class ExpressionLanguageProvider implements ExpressionFunctionProviderInterface {
  public function getFunctions() {
    return array(
      new ExpressionFunction('service', function ($arg) {
        return sprintf('$this->get(%s)', $arg);
      }, function (array $variables, $value) {
        return $variables['container']
          ->get($value);
      }),
      new ExpressionFunction('parameter', function ($arg) {
        return sprintf('$this->getParameter(%s)', $arg);
      }, function (array $variables, $value) {
        return $variables['container']
          ->getParameter($value);
      }),
    );
  }

}

Members