I have a Controller that contains the following:
...
use Magento\Backend\App\Action;
use Magento\TestFramework\ErrorLog\Logger;
use Magento\MediaStorage\Model\File\UploaderFactory;
use MyNamespace\Slider\Model\SliderImage;
class Save extends \Magento\Backend\App\Action
{
/** @var UploaderFactory */
protected $uploaderFactory;
/** @var SliderImage */
protected $imageModel;
public function __construct(
Action\Context $context,
UploaderFactory $uploaderFactory,
SliderImage $imageModel
)
{
parent::__construct($context);
$this->uploaderFactory = $uploaderFactory;
$this->imageModel = $imageModel;
}
...
}
I am using this to save a form in the admin. It was working properly without the UploaderFactory
and SliderImage
in the __contruct
.
I am now trying to add an Image field to the form.
I have added the dependencies, UploaderFactory
and SliderImage
and now get the error:
Uncaught TypeError: Argument 2 passed to MyNamespace\Slider\Controller\Adminhtml\Image\Save::__construct() must be an instance of Magento\MediaStorage\Model\File\UploaderFactory, none given, called in /var/www/html/generated/code/MyNamespace/Slider/Controller/Adminhtml/Image/Save/Interceptor.php on line 14 and defined in /var/www/html/app/code/MyNamespace/Slider/Controller/Adminhtml/Image/Save.php:19 Stack trace: #0 /var/www/html/generated/code/MyNamespace/Slider/Controller/Adminhtml/Image/Save/Interceptor.php(14): MyNamespace\Slider\Controller\Adminhtml\Image\Save->__construct(Object(Magento\Backend\App\Action\Context)) #1 /var/www/html/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(111): MyNamespace\Slider\Controller\Adminhtml\Image\Save\Interceptor->__construct(Object(Magento\Backend\App\Action\Context)) #2 /var/www/html/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('MyNamespace\Slider...', Array)