I have created the custom module as per the below tutorial:
http://www.mage-world.com/blog/grid-and-form-in-magento-2-admin-panel-part-1.html
And after I am getting the below error:
Fatal error: Class Tutorial\SimpleNews\Controller\Adminhtml\News contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Magento\Framework\App\ActionInterface::execute) in C:\xampp\htdocs\magento3\app\code\Tutorial\SimpleNews\Controller\Adminhtml\News.php on line 12
After that I have done some google and found the solution for the execute()
function in below answer:
Error in custom Admin menu controller - Magento 2
According to the answer I have changed the class name from class to abstract class.
After that I am getting the below error:
Boolean value is expected, supported values: array (
0 => true,
1 => 1,
2 => 'true',
3 => '1',
4 => false,
5 => 0,
6 => 'false',
7 => '0',
)
Please see below is the Tutorial\SimpleNews\Controller\Adminhtml\News.php file code:
<?php
namespace Tutorial\SimpleNews\Controller\Adminhtml;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;
use Tutorial\SimpleNews\Model\NewsFactory;
abstract class News extends Action
{
/**
* Authorization level
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'News_LatestNews::manage_news';
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry;
/**
* Result page factory
*
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $_resultPageFactory;
/**
* News model factory
*
* @var \Tutorial\SimpleNews\Model\NewsFactory
*/
protected $_newsFactory;
/**
* @param Context $context
* @param Registry $coreRegistry
* @param PageFactory $resultPageFactory
* @param NewsFactory $newsFactory
*/
public function __construct(
Context $context,
Registry $coreRegistry,
PageFactory $resultPageFactory,
NewsFactory $newsFactory
) {
parent::__construct($context);
$this->_coreRegistry = $coreRegistry;
$this->_resultPageFactory = $resultPageFactory;
$this->_newsFactory = $newsFactory;
}
}
Tutorial\SimpleNews\Controller\Adminhtml\News\Index.php file code:
<?php
namespace Tutorial\SimpleNews\Controller\Adminhtml\News;
use Tutorial\SimpleNews\Controller\Adminhtml\News;
class Index extends News
{
/**
* @return void
*/
public function execute()
{
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
}
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->_resultPageFactory->create();
$resultPage->setActiveMenu('Tutorial_SimpleNews::main_menu');
$resultPage->getConfig()->getTitle()->prepend(__('Simple News'));
return $resultPage;
}
}
I have done the var_dump($this->_authorization->isAllowed('News_LatestNews::manage_news'));
also it's output it bool(true)
.
Anybody, can help me how I can trace this issue?