Version 1
[yaffs-website] / vendor / symfony / dependency-injection / ExpressionLanguageProvider.php
diff --git a/vendor/symfony/dependency-injection/ExpressionLanguageProvider.php b/vendor/symfony/dependency-injection/ExpressionLanguageProvider.php
new file mode 100644 (file)
index 0000000..ce6d695
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection;
+
+use Symfony\Component\ExpressionLanguage\ExpressionFunction;
+use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
+
+/**
+ * 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>
+ */
+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);
+            }),
+        );
+    }
+}