Last active
August 31, 2022 11:27
-
-
Save mikemix/cbb9709a2f2d0588d584e40e0d5530aa to your computer and use it in GitHub Desktop.
Revisions
-
mikemix revised this gist
Aug 31, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public function __construct( protected function configure(): void { $this->setName('dev:url') ->setDescription('Generates image link') ->addArgument('strategy', InputArgument::REQUIRED) ->addArgument('size', InputArgument::REQUIRED) ->addArgument('image-id', InputArgument::REQUIRED) -
mikemix created this gist
Aug 31, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ <?php final class UrlGenerateCommand extends Command { private readonly RouterInterface $router; public function __construct( RouterInterface $router, ) { parent::__construct(); $this->router = $router; } protected function configure(): void { $this->setName('dev:url') ->setDescription('Generates image link with a valid checksum') ->addArgument('strategy', InputArgument::REQUIRED) ->addArgument('size', InputArgument::REQUIRED) ->addArgument('image-id', InputArgument::REQUIRED) ->addArgument('output-format', InputArgument::REQUIRED) ->addUsage('fixed 100x100 1/2/3.jpg webp'); } protected function execute(InputInterface $input, OutputInterface $output): int { /** @var non-empty-string $strategy */ $strategy = $input->getArgument('strategy'); /** @var non-empty-string $size */ $size = $input->getArgument('size'); /** @var non-empty-string $imageId */ $imageId = $input->getArgument('image-id'); /** @var non-empty-string $format */ $format = $input->getArgument('output-format'); $url = $this->router->generate('thumbnail_serve', [ 'strategy' => $strategy, 'size' => $size, 'id' => $imageId, 'format' => $format, ]); $output->writeln($url); return 0; } }