From 7e33bf29ebc4860250b68c7603bdfa52008e962e Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 17:16:22 +0200 Subject: [PATCH] Make sure container has a view property --- controllers/FrontController.php | 90 ++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index aabd740..2faa080 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -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); }