Создаю свою команду, при тестирование команды выпадает ошибка:
версия Symfony 4.4
php bin/console app:setup-wallpapers
In DefinitionErrorExceptionPass.php line 54:
Cannot autowire service "App\Command\SetupWallpapersCommand": argument "$rootDir" of method "__construct()" is type
-hinted "string", you should configure its value explicitly.
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SetupWallpapersCommand extends Command
{
/**
* @var string
*/
private $rootDir;
public function __construct(string $rootDir)
{
parent::__construct();
$this->rootDir = $rootDir;
}
protected static $defaultName = 'app:setup-wallpapers';
protected function configure()
{
$this
->setDescription('Add a short description for your command')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$wallpapers = glob($this->rootDir . '/public/images/*.*');
exit(\Doctrine\Common\Util\Debug::dump($wallpapers));
$output->writeln('Command result.');
}
}