Skip to content

Commit

Permalink
Fix ImageProcessor is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Jan 23, 2024
1 parent 89c8992 commit 1091229
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/Command/CreateIconsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ final class CreateIconsCommand extends Command
public function __construct(
private readonly AssetMapperInterface $assetMapper,
private readonly Filesystem $filesystem,
private readonly ImageProcessor $imageProcessor,
#[Autowire('%kernel.project_dir%')]
private readonly string $projectDir,
private readonly null|ImageProcessor $imageProcessor,
) {
parent::__construct();
}

public function isEnabled(): bool
{
return $this->imageProcessor !== null;
}

protected function configure(): void
{
$this->addArgument(
Expand Down Expand Up @@ -70,6 +75,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$io->title('PWA Icons Generator');
if ($this->imageProcessor === null) {
$io->error('The image processor is not enabled.');
return self::FAILURE;
}

$source = $input->getArgument('source');
$dest = rtrim((string) $input->getOption('output'), '/');
Expand Down
14 changes: 10 additions & 4 deletions src/Command/CreateScreenshotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ final class CreateScreenshotCommand extends Command

public function __construct(
private readonly AssetMapperInterface $assetMapper,
private readonly ImageProcessor $imageProcessor,
private readonly Filesystem $filesystem,
#[Autowire('%kernel.project_dir%')]
private readonly string $projectDir,
private readonly null|ImageProcessor $imageProcessor,
#[Autowire('@pwa.web_client')]
null|Client $webClient = null,
) {
Expand All @@ -45,6 +45,11 @@ public function __construct(
$this->webClient = $webClient;
}

public function isEnabled(): bool
{
return $this->imageProcessor !== null;
}

protected function configure(): void
{
$this->addArgument(
Expand Down Expand Up @@ -81,11 +86,12 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
if (! $this->isEnabled()) {
return self::FAILURE;
}
$io = new SymfonyStyle($input, $output);
$io->title('PWA - Take a screenshot');
if ($this->imageProcessor === null) {
$io->error('The image processor is not enabled.');
return self::FAILURE;
}

$url = $input->getArgument('url');
$dest = rtrim((string) $input->getArgument('output'), '/');
Expand Down

0 comments on commit 1091229

Please sign in to comment.