示例#1
0
 public function getPosts()
 {
     if (!$this->hasData('posts')) {
         $collection = $this->_collectionFactory->create();
         $posts = $collection->addOrder(PostInterface::CREATED_AT, Collection::SORT_ORDER_DESC);
         $this->setData('posts', $posts);
     }
     return $this->getData('posts');
 }
示例#2
0
 /**
  * Execute controller.
  *
  * @return $this
  */
 public function execute()
 {
     $collection = $this->filter->getCollection($this->collectionFactory->create());
     try {
         $this->_allAction($collection);
     } catch (\Exception $e) {
         $this->messageManager->addError($e->getMessage());
     }
     /** @var  \Magento\Backend\Model\View\Result\Redirect  $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     return $resultRedirect->setPath(static::REDIRECT_URL);
 }