【发布时间】:2021-08-09 07:04:21
【问题描述】:
我正在创建一个自定义命令行来将图像从 M1 导入到 M2。
我创建了一个运行正常的命令。现在,我正在尝试调用我的助手类来进行控制台。但是出现错误 -
In ClassReader.php line 24:
Class Company\Module\Console\ImageImportConsole\Interceptor does not exist
这里是扩展命令类-
<?php
namespace Company\Module\Console;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
class ImageImportConsole extends Command
{
const PRODUCT_ID = 'productId'; // key of parameter
protected $helper;
public function __construct(
Company\Module\Helper\Data $helper
) {
$this->helper = $helper;
}
protected function configure(){
$options = [
new InputOption(
self::PRODUCT_ID, // the option name
'-id', // the shortcut
InputOption::VALUE_REQUIRED, // the option mode
'Optional Parameter. Product entity_id. It will start importing image from this id.' // the description
),
];
$this->setName('imageimporttool:start');
$this->setDescription('Image Import Tool');
$this->setDefinition($options);
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output){
$id = $input->getOption(self::PRODUCT_ID);
// $helper = new Data();
$this->helper->test();
// if ($id) {
// // $output->writeln("Hi " . $id . ", Success!");
// } else {
// }
$output->writeln("Success");
}
}
当我尝试建立渐变时,出现此错误。
如何在命令中调用辅助类?
【问题讨论】: