2

I am trying to develop magento2.1.5 module but getting exception for my admin controller:

Boolean value is expected, supported values: array ( 0 => true, 1 => 1, 2 => 'true', 3 => '1', 4 => false, 5 => 0, 6 => 'false', 7 => '0', )

Error log record number: 763179888

here is my controller to access from admin:

namespace MyVendor\MyModule\Controller\Adminhtml\Layout;

use MyVendor\MyModule\Controller\Adminhtml\Layout;

class Index extends Layout
{
  public function __construct(
    \Magento\Backend\App\Action\Context $context
  ) 
  {
    parent::__construct($context);
  }

    /**
    * @var \Magento\Backend\Model\View\Result\Page
    */
    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('MyVendor_MyModule::main_menu');
        $resultPage->getConfig()->getTitle()->prepend(__('My Module'));

        return $resultPage;
    }
}

namespace MyVendor\MyModule\Controller\Adminhtml;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;

abstract class Layout extends Action
{
    /**
     * Authorization level
     *
     * @see _isAllowed()
     */
     const ADMIN_RESOURCE = 'MyVendor_MyModule::manage_layout';

     /**
     * Core registry
     *
     * @var \Magento\Framework\Registry
     */
    protected $_coreRegistry;

    /**
     * Result page factory
     *
     * @var \Magento\Framework\View\Result\PageFactory
     */
    protected $_resultPageFactory;

    /**
     * @param Context $context
     * @param Registry $coreRegistry
     * @param PageFactory $resultPageFactory
     */
    public function __construct(
        Context $context,
        Registry $coreRegistry,
        PageFactory $resultPageFactory
    ) {
       parent::__construct($context);
        $this->_coreRegistry = $coreRegistry;
        $this->_resultPageFactory = $resultPageFactory;
    }
}

can anybody help me what should be the reason for this error?

2 Answers2

1

This could be related.

Check your xml files especially tags with xsi:type="boolean"

Geting Error In Checkout Page Magento

Ocastro
  • 573
  • 4
  • 9
0

You have to make a __construct() function and send context of \Magento\Backend\App\Action back to parent

public function __construct(
        \Magento\Backend\App\Action\Context $context
) {
        parent::__construct($context);
    }

Please note that the context changes with each controller and depends on the class extended by the controller.

Vivek Kumar
  • 5,115
  • 2
  • 24
  • 50
  • after adding constructor on my class, you can see my update above, I am getting this error: I am getting such error: Recoverable Error: Argument 2 passed to MyVendor\MyModule\Controller\Adminhtml\Layout::__construct() must be an instance of Magento\Framework\Registry, none given, called in C:\xampp\htdocs\magento2\app\code\MyVendor\MyModule\Controller\Adminhtml\Layout\Index.php on line 13 and defined in C:\xampp\htdocs\magento2\app\code\MyVendor\MyModule\Controller\Adminhtml\Layout.php on line 40

    Error log record number: 430498555

    – Shahriat Hossain Apr 03 '17 at 14:09
  • The error which you are getting is a general error which happens when you change the parameters of __costruct() function of a controller which can be easily resolved by deleting var/generation folder in your magento's root directory .

    Also , I think you've not properly edited the code in the question as the class is defined two times , you should probably edit that . And mark my answer as correct if it helped .

    – Vivek Kumar Apr 04 '17 at 05:15