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 – Greg 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
  • thanks for answer, I upgrade my project, compile and delete cache but not works. – Alejandro Duque Jan 10 at 23:04
  • can you tell me version magento2? also, please add your controller in here to view. – the light Jan 11 at 1:53
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
0

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');
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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