public function run(CantigaController $controller, $id, $customDataGenerator = null) { try { $repository = $this->info->getRepository(); $fetch = $this->fetch; $item = $fetch($repository, $id); $nameProperty = 'get' . ucfirst($this->info->getItemNameProperty()); $name = $item->{$nameProperty}(); $customData = null; if (is_callable($customDataGenerator)) { $customData = $customDataGenerator($item); } $vars = $this->getVars(); $vars['pageTitle'] = $this->info->getPageTitle(); $vars['pageSubtitle'] = $this->info->getPageSubtitle(); $vars['item'] = $item; $vars['name'] = $name; $vars['custom'] = $customData; $vars['indexPage'] = $this->info->getIndexPage(); $vars['infoPage'] = $this->info->getInfoPage(); $vars['insertPage'] = $this->info->getInsertPage(); $vars['editPage'] = $this->info->getEditPage(); $vars['removePage'] = $this->info->getRemovePage(); $controller->breadcrumbs()->link($name, $this->info->getInfoPage(), $this->slugify(['id' => $id])); return $controller->render($this->info->getTemplateLocation() . $this->info->getInfoTemplate(), $vars); } catch (ItemNotFoundException $exception) { return $this->onError($controller, $controller->trans($this->info->getItemNotFoundErrorMessage())); } catch (ModelException $exception) { return $this->onError($controller, $controller->trans($exception->getMessage())); } }
public function showBreadcrumbs(ShowBreadcrumbsEvent $event) { if (null !== $this->controller) { $event->setBreadcrumbs($this->controller->breadcrumbs()->fetch($this->workspaceSource->getWorkspace())); } }