Skip to main content
3 of 3
Error found
user3154108
  • 447
  • 3
  • 11

Constructor called with wrong argument

Error found: Apparently the problem was that another class 'Edit' which extends 'Slide' was mispelled in the class-declaration. Instead of reporting a missing class 'Edit' it gave me that weird error.


I am trying to create an edit page in the Backend for my Entity. I have succeeded in setting up the Grid with help of several tutorials, but when I try to call upon the edit page I get just a blank page and following error in my php error.log:

[Wed May 24 12:11:10.565841 2017] [:error] [pid 29789] [client 192.168.144.27:58131] PHP Fatal error:  
Uncaught TypeError: 
Argument 1 passed to Myvendor\\Slideshow\\Controller\\Adminhtml\\Slide::__construct() must be an instance of 
    Magento\\Backend\\App\\Action\\Context, instance of Magento\\Framework\\ObjectManager\\ObjectManager given,
called in /var/www/html/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and 
defined in /var/www/html/magento2/app/code/Myvendor/Slideshow/Controller/Adminhtml/Slide.php:39

nStack trace:
#0 /var/www/html/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): 
    Myvendor\\Slideshow\\Controller\\Adminhtml\\Slide->__construct(Object(Magento\\Framework\\ObjectManager\\ObjectManager))
#1 /var/www/html/magento2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): 
    Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->createObject('Myvendor\\\\Slidesho...', Array)
#2 /var/www/html/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(57): 
    Magento\\Framework\\ObjectManager\\Factory\\Compiled->create('Myvendor\\\\Slidesho...', Array)
 #3 in /var/www/html/magento2/app/code/Myvendor/Slideshow/Controller/Adminhtml/Slide.php on line 39, 

Myvendor\Slideshow\Controller\Adminhtml\Slide.php:

namespace Myvendor\Slideshow\Controller\Adminhtml;

use Magento\Backend\App\Action;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;
use Myvendor\Slideshow\Model\SlideFactory;

abstract class Slide extends Action
{
/**
 * Core registry
 *
 * @var \Magento\Framework\Registry
 */
protected $_coreRegistry;

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

/**
 * Slide model factory
 *
 * @var \Myvendor\Slideshow\Model\SlideFactory
 */
protected $_slideFactory;

/**
 * @param \Magento\Backend\App\Action\Context $context
 * @param Registry $coreRegistry
 * @param PageFactory $resultPageFactory
 * @param SlideFactory $slideFactory
 */
public function __construct(
\Magento\Backend\App\Action\Context $context,
Registry $coreRegistry,
PageFactory $resultPageFactory,
SlideFactory $slideFactory
) 
{
    parent::__construct($context);
    $this->_coreRegistry = $coreRegistry;
    $this->_resultPageFactory = $resultPageFactory;
    $this->_slideFactory = $slideFactory;
}

/**
 * Slide access rights checking
 *
 * @return bool
 */
protected function _isAllowed()
{
    return $this->_authorization->isAllowed('Myvendor_Slideshow::manage_slide');
}
}

I am not sure what other classes or xml I need to look at to figure out where this error is coming from. This leaves me rather perplexed right now. I checked the namespaces, they seem all correct. How do I go best about debugging this?

I've cleared var/generation to no effect.

user3154108
  • 447
  • 3
  • 11