Exemplo n.º 1
0
 /**
  * Get all posts
  * @return Object \OsmanSorkar\Blog\Model\ResourceModel\Post\Collection
  */
 public function getPostCollection()
 {
     if (!$this->hasData("postCollection")) {
         $postCollection = $this->postCollectionFactory->create();
         $postCollection->addFieldToSelect("*")->addfieldToFilter("is_active", "1")->addOrder(PostInterface::CREATION_TIME, postCollection::SORT_ORDER_DESC);
         $this->setData("postCollection", $postCollection);
     }
     return $this->getData("postCollection");
 }
 /**
  * Execute action
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  * @throws \Magento\Framework\Exception\LocalizedException|\Exception
  */
 public function execute()
 {
     $collection = $this->filter->getCollection($this->collectionFactory->create());
     $collectionSize = $collection->getSize();
     foreach ($collection as $item) {
         $item->delete();
     }
     $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize));
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     return $resultRedirect->setPath('*/*/');
 }
Exemplo n.º 3
0
 public function execute()
 {
     $postCollection = $this->postCollectionFactory->create()->getData();
     return $this->resultPageFactory->create();
 }