Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search crash #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion Block/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPCuong\Faq\Model\ResourceModel\Faq as FaqResourceModel;
use Magento\Framework\App\Filesystem\DirectoryList;
use PHPCuong\Faq\Helper\Config as ConfigHelper;
use Magento\Cms\Model\Template\FilterProvider;

class Search extends \Magento\Framework\View\Element\Template
{
Expand Down Expand Up @@ -50,6 +51,12 @@ class Search extends \Magento\Framework\View\Element\Template
*/
protected $_configHelper;

/**
* @var \Magento\Cms\Model\Template\FilterProvider
*/
protected $filterProvider;


/**
*
* @param Context $context
Expand All @@ -58,20 +65,23 @@ class Search extends \Magento\Framework\View\Element\Template
* @param DirectoryList $directoryList
* @param FaqResourceModel $faqResourceModel
* @param ConfigHelper $configHelper
* @param FilterProvider $filterProvider
*/
public function __construct(
Context $context,
QuestionHelper $questionHelper,
CategoryHelper $categoryHelper,
DirectoryList $directoryList,
FaqResourceModel $faqResourceModel,
ConfigHelper $configHelper
ConfigHelper $configHelper,
FilterProvider $filterProvider
) {
$this->_questionHelper = $questionHelper;
$this->_categoryHelper = $categoryHelper;
$this->_directoryList = $directoryList;
$this->_faqResourceModel = $faqResourceModel;
$this->_configHelper = $configHelper;
$this->filterProvider = $filterProvider;
parent::__construct($context);
}

Expand Down Expand Up @@ -131,6 +141,19 @@ protected function _prepareLayout()
return parent::_prepareLayout();
}

/**
* Filter provider
*
* @param string $content
* @return string
*/
public function filterProvider($content)
{
return $this->filterProvider->getBlockFilter()
->setStoreId($this->_storeManager->getStore()->getId())
->filter($content);
}

/**
* Get FAQs via text search
*
Expand Down