4

Recoverable Error: Argument 1 passed to Webkul\Grid\Controller\Adminhtml\Grid\Index::__construct() must be an instance of Magento\Backend\App\Action\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in C:\wamp\www\Magento6\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php on line 93 and defined in C:\wamp\www\Magento6\app\code\Webkul\Grid\Controller\Adminhtml\Grid\index.php on line 23

Her is my controller code:


namespace Webkul\Grid\Controller\Adminhtml\Grid;

class Index extends \Magento\Backend\App\Action
{
    /**
     * @var \Magento\Framework\View\Result\PageFactory
     */
    protected $_resultPageFactory; 
public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) 
    {
        parent::__construct($context);
        $this->_resultPageFactory = $resultPageFactory;
    }
public function execute()
    {
        /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
        $resultPage = $this->_resultPageFactory->create();
        $resultPage->setActiveMenu('Webkul_Grid::grid_list');
        $resultPage->getConfig()->getTitle()->prepend(__('Grid List'));

        return $resultPage;
    }
a:4:{i:0;s:435:"Recoverable Error: Argument 1 passed to Webkul\Grid\Controller\Adminhtml\Grid\Index::__construct() must be an instance of Magento\Backend\App\Action\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in C:\wamp\www\Magento6\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php on line 93 and defined in C:\wamp\www\Magento6\app\code\Webkul\Grid\Controller\Adminhtml\Grid\index.php on line 23";i:1;s:3089:"#0 C:\wamp\www\Magento6\app\code\Webkul\Grid\Controller\Adminhtml\Grid\index.php(23): Magento\Framework\App\ErrorHandler->handler(4096, 'Argument 1 pass...', 'C:\\wamp\\www\\Mag...', 23, Array)
#1 C:\wamp\www\Magento6\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): Webkul\Grid\Controller\Adminhtml\Grid\Index->__construct(Object(Magento\Framework\ObjectManager\ObjectManager))
#2 C:\wamp\www\Magento6\vendor\magento\framework\ObjectManager\Factory\Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Webkul\\Grid\\Con...', Array)
#3 C:\wamp\www\Magento6\vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Webkul\\Grid\\Con...', Array)
#4 C:\wamp\www\Magento6\vendor\magento\framework\App\ActionFactory.php(40): Magento\Framework\ObjectManager\ObjectManager->create('Webkul\\Grid\\Con...')
#5 C:\wamp\www\Magento6\vendor\magento\framework\App\Router\Base.php(300): Magento\Framework\App\ActionFactory->create('Webkul\\Grid\\Con...')
#6 C:\wamp\www\Magento6\vendor\magento\framework\App\Router\Base.php(161): Magento\Framework\App\Router\Base->matchAction(Object(Magento\Framework\App\Request\Http), Array)
#7 C:\wamp\www\Magento6\vendor\magento\framework\App\FrontController.php(50): Magento\Framework\App\Router\Base->match(Object(Magento\Framework\App\Request\Http))
#8 C:\wamp\www\Magento6\vendor\magento\framework\Interception\Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#9 C:\wamp\www\Magento6\vendor\magento\framework\Interception\Chain\Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#10 C:\wamp\www\Magento6\vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#11 C:\wamp\www\Magento6\vendor\magento\framework\Module\Plugin\DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#12 C:\wamp\www\Magento6\vendor\magento\framework\Interception\Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#13 C:\wamp\www\Magento6\var\generation\Magento\Framework\App\FrontController\Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#14 C:\wamp\www\Magento6\vendor\magento\framework\App\Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#15 C:\wamp\www\Magento6\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()
#16 C:\wamp\www\Magento6\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#17 {main}";s:3:"url";s:108:"/Magento6/admin_ph7fnk/grid/grid/index/key/33f181e51ae6571909d09a1a25e0ff2d7ceae23a7a7ca26bf249af6532ab107c/";s:11:"script_name";s:19:"/Magento6/index.php";}
5

I may be wrong here, but I think you have an other class that extends \Webkul\Grid\Controller\Adminhtml\Grid\Index.
And this class has as dependency an instance of the object manager.
Something like this:

namespace Some\Namespace\Here;

class YourClassHere extends \Webkul\Grid\Controller\Adminhtml\Grid\Index 
{
    public function __construct(
        \Magento\Framework\ObjectManagerInterface $objectManager
        ....
    ) {
        ....
        parent::__contruct($objectManager, ..);
    }
}

If this is the case, make sure that in your child class constructor you call the parent constructor with the parameters that the parent class expects.
The first should be an instance of \Magento\Backend\App\Action\Context and the second an instance of \Magento\Framework\View\Result\PageFactory

  • hi marius,i did added as u said,but still cant able to get out of that error – krishnad Aug 16 '16 at 11:46
  • If I got it right, and you have a class that extends \Webkul\Grid\Controller\Adminhtml\Grid\Index please add that class to the question also. – Marius Aug 16 '16 at 11:52
  • i don't think that there is another class that extends \Webkul\Grid\Contro‌​ller\Adminhtml\Grid\I‌​ndex. i have used just only one class.. Am a beginner in magento and i just followed this link webkul.com/blog/… . can u please help me in fixing this bug – krishnad Aug 16 '16 at 12:00
  • Sorry. I have no more ideas. I was just shooting in the dark. I had the same problem you had and mine it was solved as I described above. – Marius Aug 16 '16 at 12:02
1

This kind of error happens often due to the generated files not being up to date. Flushing the var/generation folder should fix your issue

  • thanks,i flushed and again i recompiled it,but still the issue is not fixed,getting same error – krishnad Aug 16 '16 at 11:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.