summaryrefslogtreecommitdiff
path: root/src/Renderer/Twig/Extensions/Session.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Renderer/Twig/Extensions/Session.php')
-rw-r--r--src/Renderer/Twig/Extensions/Session.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Renderer/Twig/Extensions/Session.php b/src/Renderer/Twig/Extensions/Session.php
new file mode 100644
index 00000000..4690f701
--- /dev/null
+++ b/src/Renderer/Twig/Extensions/Session.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Engelsystem\Renderer\Twig\Extensions;
+
+use Symfony\Component\HttpFoundation\Session\Session as SymfonySession;
+use Twig_Extension as TwigExtension;
+use Twig_Function as TwigFunction;
+
+class Session extends TwigExtension
+{
+ /** @var SymfonySession */
+ protected $session;
+
+ /**
+ * @param SymfonySession $session
+ */
+ public function __construct(SymfonySession $session)
+ {
+ $this->session = $session;
+ }
+
+ /**
+ * @return TwigFunction[]
+ */
+ public function getFunctions()
+ {
+ return [
+ new TwigFunction('session_get', [$this->session, 'get']),
+ ];
+ }
+}