From e08b4096bc7bc5dfca03ce62f6a9e7a563aca140 Mon Sep 17 00:00:00 2001 From: Joao Inacio Date: Thu, 1 Oct 2015 15:19:45 +0100 Subject: [PATCH] Fix EZP-24897: Error on blog post pirst draft preview --- Controller/DemoController.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Controller/DemoController.php b/Controller/DemoController.php index 763bd75..6013612 100644 --- a/Controller/DemoController.php +++ b/Controller/DemoController.php @@ -156,9 +156,20 @@ public function listBlogPostsAction( $locationId ) */ public function showBlogPostAction( $locationId, $viewType, $layout = false, array $params = array() ) { - // We need the author, whatever the view type is. $repository = $this->getRepository(); - $location = $repository->getLocationService()->loadLocation( $locationId ); + if ( isset( $params['location'] ) && $params['location'] instanceof Location ) + { + $location = $params['location']; + } + else if ( is_numeric( $locationId ) ) + { + $location = $repository->getLocationService()->loadLocation( $locationId ); + } + else + { + throw new NotFoundHttpException( "Unknown location '$locationId' cannot be displayed." ); + } + // We need the author, whatever the view type is. $author = $repository->getUserService()->loadUser( $location->getContentInfo()->ownerId ); // TODO once the keyword service is available, load the number of keyword for each keyword