/** * Return a news feed from given feed id. * * @param Action $action * @param null $feedId * @return \Magento\Framework\View\Result\Page|bool */ public function prepareResultPost(Action $action, $feedId = null) { if ($feedId !== null && $feedId !== $this->_feed->getId()) { $delimiterPosition = strrpos($feedId, '|'); if ($delimiterPosition) { $feedId = substr($feedId, 0, $delimiterPosition); } if (!$this->_feed->load($feedId)) { return false; } } if (!$this->_feed->getId()) { return false; } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); // We can add our own custom page handles for layout easily. $resultPage->addHandle('news_feed_view'); // This will generate a layout handle like: news_feed_view_id_1 // giving us a unique handle to target specific news feeds if we wish to. $resultPage->addPageLayoutHandles(['id' => $this->_feed->getId()]); // Magento is event driven after all, lets remember to dispatch our own, to help people // who might want to add additional functionality, or filter the feeds somehow! $this->_eventManager->dispatch('pre_news_feed_render', ['feed' => $this->_feed, 'controller_action' => $action]); return $resultPage; }
/** * Get options * * @return array */ public function toOptionArray() { $options[] = ['label' => '', 'value' => '']; $availableOptions = $this->_feed->getAvailableStatuses(); foreach ($availableOptions as $key => $value) { $options[] = ['label' => $value, 'value' => $key]; } return $options; }