示例#1
0
文件: Post.php 项目: swnsma/practice
 public function prepareResultPost(Action $action, $id = null)
 {
     if ($id !== null && $id !== $this->_post->getId()) {
         $delimiterPosition = strpos($id, '|');
         if ($delimiterPosition) {
             $id = substr($id, 0, $delimiterPosition);
         }
         if (!$this->_post->load($id)) {
             return false;
         }
     }
     if (!$this->_post->getId()) {
         return false;
     }
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $page = $this->_pageFactory->create();
     $page->addHandle('blog_post_view');
     $page->addPageLayoutHandles(['id' => $this->_post->getId()]);
     $this->_eventManager->dispatch('ism_blog_post_render', ['post' => $this->_post, 'controller_action' => $action]);
     return $page;
 }
示例#2
0
 public function push(Post $post)
 {
     $this->postRegistryById[$post->getId()] = $post;
     $this->postRegistryByUrl[$post->getUrlKey()] = $post;
     return $this;
 }