Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / http-kernel / Controller / ArgumentResolver / SessionValueResolver.php
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\HttpKernel\Controller\ArgumentResolver;
13
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Component\HttpFoundation\Session\SessionInterface;
16 use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
17 use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
18
19 /**
20  * Yields the Session.
21  *
22  * @author Iltar van der Berg <kjarli@gmail.com>
23  */
24 final class SessionValueResolver implements ArgumentValueResolverInterface
25 {
26     /**
27      * {@inheritdoc}
28      */
29     public function supports(Request $request, ArgumentMetadata $argument)
30     {
31         $type = $argument->getType();
32         if (SessionInterface::class !== $type && !is_subclass_of($type, SessionInterface::class)) {
33             return false;
34         }
35
36         return $request->getSession() instanceof $type;
37     }
38
39     /**
40      * {@inheritdoc}
41      */
42     public function resolve(Request $request, ArgumentMetadata $argument)
43     {
44         yield $request->getSession();
45     }
46 }