_coreRegistry = $coreRegistry; $this->_filterProvider = $filterProvider; $this->_postCollectionFactory = $postCollectionFactory; $this->_url = $url; } /** * Prepare posts collection * * @return void */ protected function _preparePostCollection() { $this->_postCollection = $this->_postCollectionFactory->create() ->addActiveFilter() ->addStoreFilter($this->_storeManager->getStore()->getId()) ->setOrder('publish_time', 'DESC'); if ($this->getPageSize()) { $this->_postCollection->setPageSize($this->getPageSize()); } } /** * Prepare posts collection * * @return \Magefan\Blog\Model\ResourceModel\Post\Collection */ public function getPostCollection() { if (is_null($this->_postCollection)) { $this->_preparePostCollection(); } return $this->_postCollection; } /** * Render block HTML * * @return string */ protected function _toHtml() { if (!$this->_scopeConfig->getValue( \Magefan\Blog\Helper\Config::XML_PATH_EXTENSION_ENABLED, ScopeInterface::SCOPE_STORE )) { return ''; } return parent::_toHtml(); } }