From 7f78caba7e98d6a9c623fcf41847770db08de0f8 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 30 Mar 2025 16:16:31 +0200 Subject: [PATCH] hint about the http client when icon not found --- src/Icons/src/Registry/ChainIconRegistry.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Icons/src/Registry/ChainIconRegistry.php b/src/Icons/src/Registry/ChainIconRegistry.php index c6e882cff59..6bbf8fccc25 100644 --- a/src/Icons/src/Registry/ChainIconRegistry.php +++ b/src/Icons/src/Registry/ChainIconRegistry.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Icons\Registry; +use Symfony\Component\HttpClient\HttpClient; use Symfony\UX\Icons\Exception\IconNotFoundException; use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\IconRegistryInterface; @@ -38,6 +39,11 @@ public function get(string $name): Icon } } - throw new IconNotFoundException(\sprintf('Icon "%s" not found.', $name)); + $exceptionExtra = ''; + if (str_contains($name, ':') && !class_exists(HttpClient::class)) { + $exceptionExtra = ' If you want the on-demand registry to fetch the icon from iconfiy, you need to install "symfony/http-client".'; + } + + throw new IconNotFoundException(\sprintf('Icon "%s" not found.%s', $name, $exceptionExtra)); } }