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,9 +47,7 @@ class FrontController
{
$this->config = Config::getInstance();
$this->download = new VideoDownload();
if ($container instanceof Container) {
$this->container = $container;
}
$this->container = $container;
}
/**
@ -62,15 +60,17 @@ class FrontController
*/
public function index(Request $request, Response $response)
{
$this->container->view->render(
$response,
'index.tpl',
[
'convert' => $this->config->convert,
'class' => 'index',
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
]
);
if ($this->container instanceof Container) {
$this->container->view->render(
$response,
'index.tpl',
[
'convert' => $this->config->convert,
'class' => 'index',
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
]
);
}
}
/**
@ -83,17 +83,19 @@ class FrontController
*/
public function extractors(Request $request, Response $response)
{
$this->container->view->render(
$response,
'extractors.tpl',
[
'extractors' => $this->download->listExtractors(),
'class' => 'extractors',
'title' => 'Supported websites',
'description' => 'List of all supported websites from which Alltube Download '.
'can extract video or audio files',
]
);
if ($this->container instanceof Container) {
$this->container->view->render(
$response,
'extractors.tpl',
[
'extractors' => $this->download->listExtractors(),
'class' => 'extractors',
'title' => 'Supported websites',
'description' => 'List of all supported websites from which Alltube Download '.
'can extract video or audio files',
]
);
}
}
/**
@ -131,16 +133,18 @@ class FrontController
}
} else {
$video = $this->download->getJSON($params['url']);
$this->container->view->render(
$response,
'video.tpl',
[
'video' => $video,
'class' => 'video',
'title' => $video->title,
'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
]
);
if ($this->container instanceof Container) {
$this->container->view->render(
$response,
'video.tpl',
[
'video' => $video,
'class' => 'video',
'title' => $video->title,
'description' => 'Download "'.$video->title.'" from '.$video->extractor_key,
]
);
}
}
} else {
return $response->withRedirect($this->container->get('router')->pathFor('index'));
@ -158,15 +162,17 @@ class FrontController
*/
public function error(Request $request, Response $response, \Exception $exception)
{
$this->container->view->render(
$response,
'error.tpl',
[
'errors' => $exception->getMessage(),
'class' => 'video',
'title' => 'Error',
]
);
if ($container instanceof Container) {
$this->container->view->render(
$response,
'error.tpl',
[
'errors' => $exception->getMessage(),
'class' => 'video',
'title' => 'Error',
]
);
}
return $response->withStatus(500);
}