Allow custom cookie array in controller

This commit is contained in:
Pierre Rudloff 2017-04-25 23:04:59 +02:00
parent 5e31767140
commit 8aee9054a8
2 changed files with 5 additions and 3 deletions

View file

@ -65,8 +65,10 @@ class FrontController
* FrontController constructor. * FrontController constructor.
* *
* @param Container $container Slim dependency container * @param Container $container Slim dependency container
* @param Config $config Config instance
* @param array $cookies Cookie array
*/ */
public function __construct(ContainerInterface $container, Config $config = null) public function __construct(ContainerInterface $container, Config $config = null, array $cookies = [])
{ {
if (isset($config)) { if (isset($config)) {
$this->config = $config; $this->config = $config;
@ -77,7 +79,7 @@ class FrontController
$this->container = $container; $this->container = $container;
$this->view = $this->container->get('view'); $this->view = $this->container->get('view');
$session_factory = new \Aura\Session\SessionFactory(); $session_factory = new \Aura\Session\SessionFactory();
$session = $session_factory->newInstance($_COOKIE); $session = $session_factory->newInstance($cookies);
$this->sessionSegment = $session->getSegment('Alltube\Controller\FrontController'); $this->sessionSegment = $session->getSegment('Alltube\Controller\FrontController');
if ($this->config->stream) { if ($this->config->stream) {
$this->defaultFormat = 'best'; $this->defaultFormat = 'best';

View file

@ -28,7 +28,7 @@ $container['view'] = function ($c) {
return $view; return $view;
}; };
$controller = new FrontController($container); $controller = new FrontController($container, null, $_COOKIE);
$container['errorHandler'] = [$controller, 'error']; $container['errorHandler'] = [$controller, 'error'];