Make sure container has a view property

This commit is contained in:
Pierre Rudloff 2016-10-13 17:16:22 +02:00
parent bb1ae65733
commit 7e33bf29eb

View file

@ -47,10 +47,8 @@ class FrontController
{
$this->config = Config::getInstance();
$this->download = new VideoDownload();
if ($container instanceof Container) {
$this->container = $container;
}
}
/**
* Display index page.
@ -62,6 +60,7 @@ class FrontController
*/
public function index(Request $request, Response $response)
{
if ($this->container instanceof Container) {
$this->container->view->render(
$response,
'index.tpl',
@ -72,6 +71,7 @@ class FrontController
]
);
}
}
/**
* Display a list of extractors.
@ -83,6 +83,7 @@ class FrontController
*/
public function extractors(Request $request, Response $response)
{
if ($this->container instanceof Container) {
$this->container->view->render(
$response,
'extractors.tpl',
@ -95,6 +96,7 @@ class FrontController
]
);
}
}
/**
* Dislay information about the video.
@ -131,6 +133,7 @@ class FrontController
}
} else {
$video = $this->download->getJSON($params['url']);
if ($this->container instanceof Container) {
$this->container->view->render(
$response,
'video.tpl',
@ -142,6 +145,7 @@ class FrontController
]
);
}
}
} else {
return $response->withRedirect($this->container->get('router')->pathFor('index'));
}
@ -158,6 +162,7 @@ class FrontController
*/
public function error(Request $request, Response $response, \Exception $exception)
{
if ($container instanceof Container) {
$this->container->view->render(
$response,
'error.tpl',
@ -167,6 +172,7 @@ class FrontController
'title' => 'Error',
]
);
}
return $response->withStatus(500);
}