예제 #1
0
 /**
  * Return array of options as value-label pairs
  *
  * @return array Format: array(array('value' => '<value>', 'label' => '<label>'), ...)
  */
 public function toOptionArray()
 {
     $options[] = ['label' => '', 'value' => ''];
     $availableOptions = $this->post->getAvailableStatuses();
     foreach ($availableOptions as $key => $value) {
         $options[] = ['label' => $value, 'value' => $key];
     }
     return $options;
 }
예제 #2
0
 /**
  * @param Action\Action $action
  * @param null          $postId
  *
  * @return bool|\Magento\Framework\View\Result\Page
  */
 public function prepareResultPost(Action\Action $action, $postId = null)
 {
     if ($postId !== null && $postId !== $this->_post->getId()) {
         $position = strrpos($postId, '|');
         if ($position) {
             $postId = substr($postId, 0, $position);
         }
         if (!$this->_post->load($postId)) {
             return false;
         }
     }
     if (!$this->_post->getId()) {
         return false;
     }
     $resultPage = $this->resultPageFactory->create();
     $resultPage->addHandle('blog_post_view');
     $resultPage->addPageLayoutHandles(['id' => $this->_post->getId()]);
     $this->_eventManager->dispatch('pyvil_blog_post_render', ['post' => $this->_post, 'controller_action' => $action]);
     return $resultPage;
 }