protected function handleContent(Request $request, Content $content, ContentSpec $contentSpec = null, $handlerAction = null) { $routePrm = array(); if ($handlerAction) { $routePrm['handler'] = $handlerAction; } $redirect = null; if ($content->getGoUrl()) { $redirect = $this->redirect($content->getGoUrl()); } if (!$redirect) { $redirect = $this->get('nyrodev')->redirectIfNotUrl($this->get('nyrocms')->getUrlFor($contentSpec ? $contentSpec : $content, false, $routePrm), $this->getAllowedParams($content)); } if ($redirect) { return $redirect; } if (count($content->getContent()) === 0) { // No text content, search for the first sub content $subContents = $this->getContentRepo()->childrenForMenu($content, true); if (count($subContents)) { return $this->redirect($this->get('nyrocms')->getUrlFor($subContents[0])); } } $parents = $this->getContentRepo()->getPathForBreacrumb($content, $contentSpec ? false : true); $titles = array(); $activeIds = array(); foreach ($parents as $parent) { $activeIds[$parent->getId()] = $parent->getId(); $titles[] = $parent->getTitle(); } $activeIds[$content->getId()] = $content->getId(); $this->get('nyrocms')->setActiveIds($activeIds); $this->get('nyrocms')->setPathInfoObject($contentSpec ? $contentSpec : $content); if ($content->getContentHandler()) { $handler = $this->get('nyrocms')->getHandler($content->getContentHandler()); $handler->init($request); $contentHandler = $handler->prepareView($content, $contentSpec, $handlerAction); if ($contentHandler instanceof Response) { return $contentHandler; } } $title = count($titles) ? implode(', ', $titles) : null; $description = $content->getSummary(); $image = $content->getFirstImage(); if ($contentSpec) { $title = $contentSpec->getTitle() . ' - ' . $content->getTitle() . ', ' . $title; $description = $contentSpec->getSummary(); if ($contentSpec->getFirstImage()) { $image = $contentSpec->getFirstImage(); } } else { $title = $content->getTitle() . ($title ? ', ' . $title : null); } $this->setTitle($title); $this->setDescription($description); if ($image) { $this->setImage($this->get('nyrocms_composer')->imageResize($image, 1000)); } return $this->handleContentView($request, $content, $parents, $contentSpec, $handlerAction); }