1

I just cloned a project from git, everyting ok, when i enter to a module name kardex i found this error, the thing is that this error only appears to me in my project, not happen in another cloned project from my team. I upgrade my project, compile and delete cache but not works, thanks for the help.

PHP Fatal error: Uncaught TypeError: Argument 1 passed to Arkix\kardex\Controller\Adminhtml\Inventory\Index::__construct() must be an  
instance of Magento\Backend\App\Action\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in  C:\laragon\www\babalu\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php on line 93 and defined in  C:\laragon\www\babalu\app\code\Arkix\Kardex\Controller\Adminhtml\Inventory\Index.php:23   
Stack trace:  
#0 C:\laragon\www\babalu\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): Arkix\kardex\Controller\Adminhtml\Inventory\Index->__construct(Object(Magento\Framework\ObjectManager\ObjectManager))   
#1 C:\laragon\www\babalu\vendor\magento\framework\ObjectManager\Factory\Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Arkix\\Kardex\\Co...', Array)   
#2 C:\laragon\www\babalu\vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Arkix\\Kardex\\Co in C:\laragon\www\babalu\app\code\Arkix\Kardex\Controller\Adminhtml\Inventory\Index.php on line 23

this is my controller, i´m using magento 2.1, the error appears in the line 23 but i don´t know.

<?php

namespace Arkix\kardex\Controller\Adminhtml\Inventory;

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

class Index extends Action
{
    /**
     * @var PageFactory
     */
    protected $resultPageFactory;

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

    /**
     * Index action
     *
     * @return \Magento\Backend\Model\View\Result\Page
     */
    public function execute()
    {
        /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
        $resultPage = $this->resultPageFactory->create();

        $resultPage->addBreadcrumb(__('Kardex'), __('Kardex'));
        $resultPage->addBreadcrumb(__('Kardex'), __('Kardex'));
        $resultPage->getConfig()->getTitle()->prepend(__('Kardex'));

        return $resultPage;
    }

     /**
     * @return bool
     */
    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed('Arkix_Kardex::kardex_inventory');
    }
}
  • 1
    remove/rename generated folder at magento's root. – Vivek Kumar Jan 9 at 21:02
  • You namespace has a misspelling – Bare Feet Jan 11 at 13:37
0

it was caused by you modify construct of that controller. Use command compile to solve it:

php bin/magento setup:di:compile
0

Good Day bro this is my controller, i´m using magento 2.1, the error appears in the line 23 but i don´t know.

<?php

namespace Arkix\kardex\Controller\Adminhtml\Inventory;

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

class Index extends Action
{
    /**
     * @var PageFactory
     */
    protected $resultPageFactory;

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

    /**
     * Index action
     *
     * @return \Magento\Backend\Model\View\Result\Page
     */
    public function execute()
    {
        /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
        $resultPage = $this->resultPageFactory->create();

        $resultPage->addBreadcrumb(__('Kardex'), __('Kardex'));
        $resultPage->addBreadcrumb(__('Kardex'), __('Kardex'));
        $resultPage->getConfig()->getTitle()->prepend(__('Kardex'));

        return $resultPage;
    }

     /**
     * @return bool
     */
    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed('Arkix_Kardex::kardex_inventory');
    }
}
New contributor
Alejandro Duque is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

Try to change namespace from:

namespace Arkix\kardex\Controller\Adminhtml\Inventory;

to:

namespace Arkix\Kardex\Controller\Adminhtml\Inventory;
  • i´m going to try out your suggestion Siarhey, thanks for answer. – Alejandro Duque Jan 11 at 14:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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