在Magento 2.2中,我创建了一个模块,我收到了这个错误 .
未捕获的TypeError:传递给__construct()的参数1必须是Magento \ Backend \ Block \ Template \ Context的实例,给出Magento \ Framework \ ObjectManager \ ObjectManager的实例
我的文件路径 app\code\Namespace\Modulename\Block\Adminhtml\Exporter\Edit\Tab\Form.php
<?php
namespace Namespace\Modulename\Block\Adminhtml\Exporter\Edit\Tab;
class Form extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
protected $exporter;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Raveinfosys\Orderexporter\Model\Exporter $exporter,
array $data = []
) {
$this->exporter = $exporter;
$this->_formFactory = $formFactory;
parent::__construct($context, $registry, $formFactory, $data);
}
他们在显示错误
公共职能__construct
1 回答
通常,Magento在
var/generation
文件夹中缓存构造函数,因此如果清除var/generation
内容,则Magento将重新生成拦截器 .