File tree Expand file tree Collapse file tree
DependencyInjection/Compiler Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the FOSUserBundle package.
5+ *
6+ * (c) FriendsOfSymfony <http://friendsofsymfony.github.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 FOS \UserBundle \DependencyInjection \Compiler ;
13+
14+ use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
15+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
16+ use Symfony \Flex \Recipe ;
17+
18+ /**
19+ * Checks to see if the session service exists.
20+ *
21+ * @author Ryan Weaver <ryan@knpuniversity.com>
22+ */
23+ class CheckForSessionPass implements CompilerPassInterface
24+ {
25+ /**
26+ * {@inheritdoc}
27+ */
28+ public function process (ContainerBuilder $ container )
29+ {
30+ if (!$ container ->has ('session ' )) {
31+ $ message = 'FOSUserBundle requires the "session" service to be available. ' ;
32+
33+ if (class_exists (Recipe::class)) {
34+ $ message .= ' Uncomment the "session" section in "config/packages/framework.yaml" to activate it. ' ;
35+ }
36+
37+ throw new \LogicException ($ message );
38+ }
39+ }
40+ }
Original file line number Diff line number Diff line change 1414use Doctrine \Bundle \CouchDBBundle \DependencyInjection \Compiler \DoctrineCouchDBMappingsPass ;
1515use Doctrine \Bundle \DoctrineBundle \DependencyInjection \Compiler \DoctrineOrmMappingsPass ;
1616use Doctrine \Bundle \MongoDBBundle \DependencyInjection \Compiler \DoctrineMongoDBMappingsPass ;
17+ use FOS \UserBundle \DependencyInjection \Compiler \CheckForSessionPass ;
1718use FOS \UserBundle \DependencyInjection \Compiler \InjectRememberMeServicesPass ;
1819use FOS \UserBundle \DependencyInjection \Compiler \InjectUserCheckerPass ;
1920use FOS \UserBundle \DependencyInjection \Compiler \ValidationPass ;
@@ -35,6 +36,7 @@ public function build(ContainerBuilder $container)
3536 $ container ->addCompilerPass (new ValidationPass ());
3637 $ container ->addCompilerPass (new InjectUserCheckerPass ());
3738 $ container ->addCompilerPass (new InjectRememberMeServicesPass ());
39+ $ container ->addCompilerPass (new CheckForSessionPass ());
3840
3941 $ this ->addRegisterMappingsPass ($ container );
4042 }
You can’t perform that action at this time.
0 commit comments