summaryrefslogtreecommitdiff
path: root/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2018-01-19 15:40:08 +0000
committerGreg Roach <fisharebest@gmail.com>2018-01-19 22:39:48 +0000
commit9499ed38534b88c310649782326f430b724fbe3a (patch)
tree3b10195a8e8e56024f75403869d5a56074314181 /vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php
parentc9b4efa1714b4374cc3446e0d3a1935da0cb3a59 (diff)
downloadwebtrees-9499ed38534b88c310649782326f430b724fbe3a.tar.gz
webtrees-9499ed38534b88c310649782326f430b724fbe3a.tar.bz2
webtrees-9499ed38534b88c310649782326f430b724fbe3a.zip
Add symfony/http-kernel
Diffstat (limited to 'vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php')
-rw-r--r--vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php b/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php
new file mode 100644
index 0000000000..9e656d281b
--- /dev/null
+++ b/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php
@@ -0,0 +1,46 @@
+<?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\HttpKernel\Controller\ArgumentResolver;
+
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
+use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
+use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
+
+/**
+ * Yields the Session.
+ *
+ * @author Iltar van der Berg <kjarli@gmail.com>
+ */
+final class SessionValueResolver implements ArgumentValueResolverInterface
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function supports(Request $request, ArgumentMetadata $argument)
+ {
+ $type = $argument->getType();
+ if (SessionInterface::class !== $type && !is_subclass_of($type, SessionInterface::class)) {
+ return false;
+ }
+
+ return $request->getSession() instanceof $type;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function resolve(Request $request, ArgumentMetadata $argument)
+ {
+ yield $request->getSession();
+ }
+}