<NME> SessionServiceProvider.php
<BEF> <?php

namespace Bolt\Provider;

use Bolt\Session\Bridge;
use Silex\Application;
use Silex\ServiceProviderInterface;

/**
 * Session service provider.
 *
 * @author Carson Full <carsonfull@gmail.com>
 */
class SessionServiceProvider implements ServiceProviderInterface
{
    /**
     * {@inheritdoc}
     */
    public function register(Application $app)
    {
        if (!isset($app['session'])) {
            $app->register(new Bridge\Silex1\SessionServiceProvider());
        }

        $app['session.options'] = function () use ($app) {
            $config = $app['config'];

            return $config->get('general/session', []) + [
                'name'            => 'bolt_session',
                'restrict_realm'  => true,
                'cookie_lifetime' => $config->get('general/cookies_lifetime'),
                'cookie_domain'   => $config->get('general/cookies_domain'),
                'cookie_secure'   => $config->get('general/enforce_ssl'),
                'cookie_httponly' => true,
            ];
        };

        $app['session.options_bag'] = $app->share(
            $app->extend(
                'session.options_bag',
                function ($options) {
                    // PHP's native C code accesses filesystem with different permissions than userland code.
                    // If php.ini is using the default (files) handler, use ours instead to prevent this problem.
                    if ($options['save_handler'] === 'files') {
                        $options['save_handler'] = 'filesystem';
                        $options['save_path'] = 'cache://.sessions';
                    }

                    return $options;
                }
            )
        );
    }

    /**
     * {@inheritdoc}
        $this->configure($app);
    }

    /**
     * This should be the only place in this class that is specific to bolt.
     *
        ];
    }

    public function registerSessions(Application $app)
    {
        $app['sessions'] = $app->share(function () use ($app) {
            $app['sessions.options.initializer']();
        });
    }

    public function registerListeners(Application $app)
    {
        $app['sessions.listener'] = $app->share(function () use ($app) {
            $app['sessions.options.initializer']();
        $this->registerRedisHandler($app);
    }

    public function boot(Application $app)
    {
        $listeners = $app['sessions.listener'];
        foreach ($listeners->keys() as $name) {
            $app['dispatcher']->addSubscriber($listeners[$name]);
        }
        foreach ($app['sessions.options'] as $options) {
            /** @var $options OptionsBag */
            if ($options->getBoolean('cookie_restrict_path')) {
                $listener = $app['session.cookie_path_restriction_listener.factory']($options);
                $app['dispatcher']->addSubscriber($listener);
            }
        }
    }

    protected function registerMemcacheHandler(Application $app)
    {
        $app['session.storage.handler.factory.backing_memcache'] = $app->protect(function ($connections) {

<MSG> [Session] Reordered methods in SP

<DFF> @@ -57,6 +57,21 @@ class SessionServiceProvider implements ServiceProviderInterface
         $this->configure($app);
     }
 
+    public function boot(Application $app)
+    {
+        $listeners = $app['sessions.listener'];
+        foreach ($listeners->keys() as $name) {
+            $app['dispatcher']->addSubscriber($listeners[$name]);
+        }
+        foreach ($app['sessions.options'] as $options) {
+            /** @var $options OptionsBag */
+            if ($options->getBoolean('cookie_restrict_path')) {
+                $listener = $app['session.cookie_path_restriction_listener.factory']($options);
+                $app['dispatcher']->addSubscriber($listener);
+            }
+        }
+    }
+
     /**
      * This should be the only place in this class that is specific to bolt.
      *
@@ -83,7 +98,7 @@ class SessionServiceProvider implements ServiceProviderInterface
         ];
     }
 
-    public function registerSessions(Application $app)
+    protected function registerSessions(Application $app)
     {
         $app['sessions'] = $app->share(function () use ($app) {
             $app['sessions.options.initializer']();
@@ -122,7 +137,7 @@ class SessionServiceProvider implements ServiceProviderInterface
         });
     }
 
-    public function registerListeners(Application $app)
+    protected function registerListeners(Application $app)
     {
         $app['sessions.listener'] = $app->share(function () use ($app) {
             $app['sessions.options.initializer']();
@@ -247,21 +262,6 @@ class SessionServiceProvider implements ServiceProviderInterface
         $this->registerRedisHandler($app);
     }
 
-    public function boot(Application $app)
-    {
-        $listeners = $app['sessions.listener'];
-        foreach ($listeners->keys() as $name) {
-            $app['dispatcher']->addSubscriber($listeners[$name]);
-        }
-        foreach ($app['sessions.options'] as $options) {
-            /** @var $options OptionsBag */
-            if ($options->getBoolean('cookie_restrict_path')) {
-                $listener = $app['session.cookie_path_restriction_listener.factory']($options);
-                $app['dispatcher']->addSubscriber($listener);
-            }
-        }
-    }
-
     protected function registerMemcacheHandler(Application $app)
     {
         $app['session.storage.handler.factory.backing_memcache'] = $app->protect(function ($connections) {

{'addition_count': 17, 'commit_subject': '[Session] Reordered methods in SP', 'deletion_count': 17, 'file_extension': '.php', 'lang': 'php', 'license': 'mit', 'repo_name': 'bolt/bolt'}