I am creating one module. But in the controller getting following error.
Fatal error: Class HK\Faq\Controller\Faqs contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Magento\Framework\App\ActionInterface::execute) in \app\code\HK\Faq\Controller\Faqs.php on line 12
Here is the Faqs.php file I am not getting what is wrong in this file.
<?php
namespace HK\Faq\Controller;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Result\PageFactory;
//use HK\Faq\Helper\Data;
use HK\Faq\Model\FaqFactory;
class Faqs extends Action
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $_pageFactory;
protected $_dataHelper;
protected $_faqFactory;
/**
* @param Context $context
* @param PageFactory $pageFactory
* @param Data $dataHelper
* @param NewsFactory $faqsFactory
*/
public function __construct(
Context $context,
PageFactory $pageFactory,
//Data $dataHelper,
FaqFactory $faqFactory
) {
parent::__construct($context);
$this->_pageFactory = $pageFactory;
//$this->_dataHelper = $dataHelper;
$this->_faqFactory = $faqFactory;
}
/**
* Dispatch request
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function dispatch(RequestInterface $request)
{
// Check this module is enabled in frontend
$result = parent::dispatch($request);
return $result;
/*if ($this->_dataHelper->isEnabledInFrontend()) {
$result = parent::dispatch($request);
return $result;
} else {
$this->_forward('noroute');
}*/
}
}
Best Answer
Add execute method that is required.