Magento2:Extra 传递给父构造的参数:

Magento2:Extra parameters passed to parent construct:

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

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:

虽然我在模块的工作中没有遇到任何问题,但我已经遵循了另一个 post 的代码。

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

所以你应该打电话给

parent::__construct($context);

而不是

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