I am trying to define 2 models inside controller constructor to use it later inside execute function. This is my code:
namespace Company\Modul\Controller\Adminhtml\Index;
use Magento\Backend\App\Action;
class Save extends \Magento\Backend\App\Action
{
protected $dataProcessor;
protected $appEmulation;
protected $filterProvider;
public function __construct(
\Magento\Store\Model\App\Emulation $appEmulation,
\Magento\Cms\Model\Template\FilterProvider $filterProvider,
Action\Context $context,
PostDataProcessor $dataProcessor)
{
$this->dataProcessor = $dataProcessor;
$this->filterProvider = $filterProvider;
$this->appEmulation = $appEmulation;
parent::__construct($context);
}
public function execute()
{
$data = $this->getRequest()->getPostValue();
$this->appEmulation->startEnvironmentEmulation(1);
//some more code...
$this->_redirect('*/*/');
}
}
I am getting this error:
Recoverable Error: Argument 2 passed to Company\Module\Controller\Adminhtml\Index\Save::__construct() must be an instance of Magento\Cms\Model\Template\FilterProvider, instance of Magento\Backend\App\Action\Context given, called in C:\wamp\www\magento2b\var\generation\Company\Module\Controller\Adminhtml\Index\Save\Interceptor.php on line 14 and defined in C:\wamp\www\magento2b\app\code\Company\Module\Controller\Adminhtml\Index\Save.php on line 16
What am I doing wrong, what would be a proper way to access filterProvider
?