@@ -27,15 +27,17 @@ class SessionSupportCompilerPass extends BaseCompilerPass
2727 */
2828 protected function prepare ()
2929 {
30- // If there is no active session support, return
31- if (!$ this ->container ->hasAlias ( ' session.storage ' )) {
30+ // Check if session support is enabled
31+ if (!$ this ->container ->hasParameter ( $ this -> getAlias (). ' .session ' )) {
3232 return ;
3333 }
3434
35- // If the aequasi.cache.session_handler service is loaded set the alias
36- if ($ this ->container ->hasParameter ( $ this -> getAlias () . ' . session ' )) {
37- $ this -> enableSessionSupport ( $ this -> container -> getParameter ( $ this -> getAlias () . ' . session' ) );
35+ // If there is no active session support, throw
36+ if (! $ this ->container ->hasAlias ( ' session.storage ' )) {
37+ throw new \ Exception ( " Session cache support cannot be enabled if there is no session.storage service " );
3838 }
39+
40+ $ this ->enableSessionSupport ($ this ->container ->getParameter ($ this ->getAlias ().'.session ' ));
3941 }
4042
4143 /**
@@ -51,17 +53,16 @@ private function enableSessionSupport(array $config)
5153 throw new InvalidConfigurationException ("Instance must be passed under the `session` config. " );
5254 }
5355
54- $ instance = $ config ['instance ' ];
55- $ instances = $ this ->container ->getParameter ($ this ->getAlias () . '.instance ' );
56+ $ instance = $ config ['instance ' ];
57+ $ instances = $ this ->container ->getParameter ($ this ->getAlias (). '.instance ' );
5658
57- if (null === $ instance ) {
58- return ;
59- }
6059 if (!isset ($ instances [$ instance ])) {
61- throw new InvalidConfigurationException (sprintf (
62- "Failed to hook into the session. The instance \"%s \" doesn't exist! " ,
63- $ instance
64- ));
60+ throw new InvalidConfigurationException (
61+ sprintf (
62+ "Failed to hook into the session. The instance \"%s \" doesn't exist! " ,
63+ $ instance
64+ )
65+ );
6566 }
6667
6768 // calculate options
0 commit comments