/** * @return \Magento\Framework\Controller\Result\Forward|\Magento\Framework\View\Result\Page */ public function execute() { $authorId = (int) $this->getRequest()->getParam('id'); $author = $this->authorFactory->create(); $author->load($authorId); if (!$author->isActive()) { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } $this->coreRegistry->register('current_author', $author); $resultPage = $this->resultPageFactory->create(); $title = $author->getMetaTitle() ?: $author->getName(); $resultPage->getConfig()->getTitle()->set($title); $resultPage->getConfig()->setDescription($author->getMetaDescription()); $resultPage->getConfig()->setKeywords($author->getMetaKeywords()); if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) { /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbsBlock */ $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbsBlock) { $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'link' => $this->_url->getUrl('')]); $breadcrumbsBlock->addCrumb('authors', ['label' => __('Authors'), 'link' => $this->urlModel->getListUrl()]); $breadcrumbsBlock->addCrumb('author-' . $author->getId(), ['label' => $author->getName()]); } } return $resultPage; }
/** * @return array */ public function getRssData() { $url = $this->urlModel->getListUrl(); $data = ['title' => __('Authors'), 'description' => __('Authors'), 'link' => $url, 'charset' => 'UTF-8']; $collection = $this->authorCollectionFactory->create(); $collection->addStoreFilter($this->getStoreId()); $collection->addFieldToFilter('is_active', 1); //TODO: use constant $collection->addFieldToFilter('in_rss', 1); //TODO: use constant foreach ($collection as $item) { /** @var \Sample\News\Model\Author $item */ //TODO: add more attributes to RSS $description = '<table><tr><td><a href="%s">%s</a></td></tr></table>'; $description = sprintf($description, $item->getAuthorUrl(), $item->getName()); $data['entries'][] = ['title' => $item->getName(), 'link' => $item->getAuthorUrl(), 'description' => $description]; } return $data; }
/** * @return mixed */ public function getAuthorUrl() { return $this->urlModel->getAuthorUrl($this); }