0

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.

4
  • please share full code of above file. Commented May 24, 2017 at 12:04
  • Remove var/generation folder Commented May 24, 2017 at 12:07
  • @RakeshJesadiya I've included the whole class in the question Commented May 24, 2017 at 13:22
  • @PrincePatel clearing var/generation has no effect Commented May 24, 2017 at 13:22

1 Answer 1

0

Try this code.

public function __construct(
\Magento\Backend\App\Action\Context $context,
Registry $coreRegistry,
PageFactory $resultPageFactory,
SlideFactory $slideFactory
) 
{
    $this->_coreRegistry = $coreRegistry;
    $this->_resultPageFactory = $resultPageFactory;
    $this->_slideFactory = $slideFactory;
    parent::__construct($context);
}
3
  • I changed it and recompiled but it changes nothing. Also tried a return parent::__construct($context) but same error. Commented May 24, 2017 at 14:17
  • Have you try to clear your browser cache one's and then try. Commented May 25, 2017 at 3:31
  • I have. I have really no clue why this isn't working. Could it be that the constructor is called at some point with the wrong arguments? Commented May 29, 2017 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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