Better container handling

This commit is contained in:
Pierre Rudloff 2016-10-23 22:59:37 +02:00
parent 6133b6a26e
commit 8505a7e99f

View file

@ -46,6 +46,12 @@ class FrontController
*/
private $sessionSegment;
/**
* Smarty view
* @var \Slim\Views\Smarty
*/
private $view;
/**
* FrontController constructor.
*
@ -56,6 +62,7 @@ class FrontController
$this->config = Config::getInstance();
$this->download = new VideoDownload();
$this->container = $container;
$this->view = $this->container->get('view');
$session_factory = new \Aura\Session\SessionFactory();
$session = $session_factory->newInstance($_COOKIE);
$this->sessionSegment = $session->getSegment('Alltube\Controller\FrontController');
@ -71,8 +78,7 @@ class FrontController
*/
public function index(Request $request, Response $response)
{
if ($this->container instanceof Container) {
$this->container->view->render(
$this->view->render(
$response,
'index.tpl',
[
@ -82,7 +88,6 @@ class FrontController
]
);
}
}
/**
* Display a list of extractors.
@ -94,8 +99,7 @@ class FrontController
*/
public function extractors(Request $request, Response $response)
{
if ($this->container instanceof Container) {
$this->container->view->render(
$this->view->render(
$response,
'extractors.tpl',
[
@ -107,7 +111,6 @@ class FrontController
]
);
}
}
/**
* Display a password prompt.
@ -119,8 +122,7 @@ class FrontController
*/
public function password(Request $request, Response $response)
{
if ($this->container instanceof Container) {
$this->container->view->render(
$this->view->render(
$response,
'password.tpl',
[
@ -130,7 +132,6 @@ class FrontController
]
);
}
}
/**
* Dislay information about the video.
@ -176,8 +177,7 @@ class FrontController
} catch (PasswordException $e) {
return $this->password($request, $response);
}
if ($this->container instanceof Container) {
$this->container->view->render(
$this->view->render(
$response,
'video.tpl',
[
@ -188,7 +188,6 @@ class FrontController
]
);
}
}
} else {
return $response->withRedirect($this->container->get('router')->pathFor('index'));
}
@ -205,8 +204,7 @@ class FrontController
*/
public function error(Request $request, Response $response, \Exception $exception)
{
if ($this->container instanceof Container) {
$this->container->view->render(
$this->view->render(
$response,
'error.tpl',
[
@ -215,7 +213,6 @@ class FrontController
'title' => 'Error',
]
);
}
return $response->withStatus(500);
}