Php Magento2:传递给父构造的额外参数:

Php Magento2:传递给父构造的额外参数:,php,magento-2.0,Php,Magento 2.0,我的自定义控制器中有以下代码: namespace Myweb\CustomArt\Controller\Index; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Filesystem; class Form extends \Magento\Framework\App\Action\Action { /** * Contact action * * @retur

我的自定义控制器中有以下代码:

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设置:di:compile

传递给父构造的额外参数:$transportBuilder、$inlineTranslation、$scopeConfig。文件:


我从另一篇文章中了解了这段代码,尽管我在模块的工作中没有遇到任何问题。

您正在扩展
\Magento\Framework\App\Action\Action
,其构造函数只有一个参数:
\Magento\Framework\App\Action\Context

所以你应该打电话

parent::__construct($context);
而不是

parent::__construct($context, $transportBuilder, $inlineTranslation, $scopeConfig);

谢谢,我已经按照你提到的方式解决了。但这是你的正确答案。因此被接受并投票表决。