我在自定义控制器中有这个代码:
namespace Myweb\CustomArt\Controller\Index;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Filesystem;
class Form extends \Magento\Framework\App\Action\Action
{
/**
* Contact action
*
* @return void
*/
/**
* @var \Magento\Framework\Mail\Template\TransportBuilder
*/
/**
* @var Google reCaptcha Options
*/
private static $_siteVerifyUrl = "https://www.google.com/recaptcha/api/siteverify?";
private $_secret;
private static $_version = "php_7.0";
/**
* Save Form Data
*
* @return array
*/
protected $context;
private $fileUploaderFactory;
private $fileSystem;
protected $_transportBuilder;
protected $scopeConfig;
protected $inlineTranslation;
public function __construct(
\Magento\Framework\App\Action\Context $context,
Filesystem $fileSystem,
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory
) {
parent::__construct($context, $transportBuilder, $inlineTranslation, $scopeConfig );
$this->fileUploaderFactory = $fileUploaderFactory;
$this->fileSystem = $fileSystem;
$this->_transportBuilder = $transportBuilder;
$this->inlineTranslation = $inlineTranslation;
$this->scopeConfig = $scopeConfig;
}
运行命令时,我收到如下错误
php bin/magento setup:di:compile
Extra parameters passed to parent construct: $transportBuilder, $inlineTranslation, $scopeConfig. File:
我已经从另一篇文章中跟踪了这段代码,但我在模块的工作中没有遇到任何问题。
答案 0 :(得分:2)
您正在扩展\Magento\Framework\App\Action\Action
,其构造函数只有一个参数:\Magento\Framework\App\Action\Context
。
所以你应该打电话给
parent::__construct($context);
而不是
parent::__construct($context, $transportBuilder, $inlineTranslation, $scopeConfig);