/** * Creates the application. * * @return Synapse\Application */ public function createApplicationWithServices(array $services) { defined('WEBDIR') or define('WEBDIR', realpath(__DIR__)); defined('APPDIR') or define('APPDIR', realpath(WEBDIR . '/..')); defined('DATADIR') or define('DATADIR', APPDIR . '/data'); defined('TMPDIR') or define('TMPDIR', '/tmp'); date_default_timezone_set('UTC'); $applicationInitializer = new Synapse\ApplicationInitializer(); $app = $applicationInitializer->initialize(); $app->register(new \Silex\Provider\SecurityServiceProvider()); $app->register(new \Synapse\Controller\ControllerServiceProvider()); $app->register(new \Silex\Provider\UrlGeneratorServiceProvider()); $app['security.firewalls'] = $app->share(function () { return ['base.api' => ['pattern' => '^/', 'oauth' => true]]; }); $app['security.access_rules'] = $app->share(function () { return []; }); // synapse's default session provider doesn't allow for testing so override $sessionServiceProvider = new SessionServiceProvider(); $sessionServiceProvider->register($app); $app['debug'] = true; $app['session.test'] = true; $app['exception_handler']->disable(); foreach ($services as $service) { $app->register($service); } $this->setupOAuth2Provider($app); return $app; }
public function onEarlyKernelRequest(GetResponseEvent $event) { parent::onEarlyKernelRequest($event); if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { return; } $request = $event->getRequest(); $handler = $this->app['session.storage.handler']; $handler->setRequest($request); $data = unserialize($handler->read('')); $this->debug('> session data', ['session_data' => $data]); $this->app['session']->replace(is_array($data) && $data > 0 ? $data : []); }
public function register(Application $app) { parent::register($app); $app['session.storage'] = $app->share(function ($app) { return new JwtCookieSessionStorage($app['session.storage.cookie.name'], $app['session.storage.cookie.secret']); }); $app['session.bag.attribute'] = function ($app) { return new AutoSavingAttributeBag($app['session.storage']); }; $app['session'] = $app->share(function ($app) { return new Session($app['session.storage'], $app['session.bag.attribute']); }); }
public function register(Application $app) { parent::register($app); /** @noinspection PhpParamsInspection */ $app['session.storage.handler'] = $app->share(function ($app) { $config = $app['session.dynamodb.options']; if (!array_key_exists('dynamodb_client', $config)) { $config['dynamodb_client'] = $this->getDynamoDbClient($app['aws']); } return SessionHandler::factory($config); }); $app['session.dynamodb.options'] = array(); }
public function subscribe(Container $app, EventDispatcherInterface $dispatcher) { $dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'), 0); parent::subscribe($app, $dispatcher); }