From d592cd7dd4c88cffc0cef76cb5711620fc242ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Sun, 20 Oct 2024 15:39:28 +0200 Subject: [PATCH] [Icons] Improve `icons:lock` command verbosity * display "Icon Not Found" (verbose) * display "IconSet Not Found" (very verbose) --- src/Icons/src/Command/LockIconsCommand.php | 13 ++++++++++++- src/Icons/src/Iconify.php | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Icons/src/Command/LockIconsCommand.php b/src/Icons/src/Command/LockIconsCommand.php index c58a258f9e3..e452a7d723d 100644 --- a/src/Icons/src/Command/LockIconsCommand.php +++ b/src/Icons/src/Command/LockIconsCommand.php @@ -72,10 +72,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int [$prefix, $name] = $parts; + if (!$this->iconify->hasIconSet($prefix)) { + // not an icon set? example: "og:twitter" + if ($io->isVeryVerbose()) { + $io->writeln(\sprintf(' ✗ IconSet Not Found: %s:%s.', $prefix, $name)); + } + continue; + } + try { $svg = $this->iconify->fetchSvg($prefix, $name); } catch (IconNotFoundException) { // icon not found on iconify + if ($io->isVerbose()) { + $io->writeln(\sprintf(' ✗ Icon Not Found: %s:%s.', $prefix, $name)); + } continue; } @@ -84,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $license = $this->iconify->metadataFor($prefix)['license']; ++$count; - $io->text(\sprintf( + $io->writeln(\sprintf( " ✓ Imported %s:%s (License: %s). Render with: {{ ux_icon('%s') }}", $prefix, $name, diff --git a/src/Icons/src/Iconify.php b/src/Icons/src/Iconify.php index d9d3fa15b02..be2d9c4806f 100644 --- a/src/Icons/src/Iconify.php +++ b/src/Icons/src/Iconify.php @@ -99,6 +99,11 @@ public function fetchSvg(string $prefix, string $name): string return $content; } + public function hasIconSet(string $prefix): bool + { + return isset($this->sets()[$prefix]); + } + public function getIconSets(): array { return $this->sets()->getArrayCopy();