|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\DependencyInjection\Loader; |
| 13 | + |
| 14 | +class UndefinedExtensionHandler |
| 15 | +{ |
| 16 | + private const BUNDLE_EXTENSIONS = [ |
| 17 | + 'debug' => 'DebugBundle', |
| 18 | + 'doctrine' => 'DoctrineBundle', |
| 19 | + 'doctrine_migrations' => 'DoctrineMigrationsBundle', |
| 20 | + 'framework' => 'FrameworkBundle', |
| 21 | + 'maker' => 'MakerBundle', |
| 22 | + 'monolog' => 'MonologBundle', |
| 23 | + 'security' => 'SecurityBundle', |
| 24 | + 'twig' => 'TwigBundle', |
| 25 | + 'twig_component' => 'TwigComponentBundle', |
| 26 | + 'ux_icons' => 'UXIconsBundle', |
| 27 | + 'web_profiler' => 'WebProfilerBundle', |
| 28 | + ]; |
| 29 | + |
| 30 | + public static function getErrorMessage(string $extensionName, ?string $loadingFilePath, string $namespaceOrAlias, array $foundExtensionNamespaces): string |
| 31 | + { |
| 32 | + $message = ''; |
| 33 | + if (isset(self::BUNDLE_EXTENSIONS[$extensionName])) { |
| 34 | + $message .= sprintf('Did you forget to install or enable the %s? ', self::BUNDLE_EXTENSIONS[$extensionName]); |
| 35 | + } |
| 36 | + |
| 37 | + $message .= match (true) { |
| 38 | + \is_string($loadingFilePath) => sprintf('There is no extension able to load the configuration for "%s" (in "%s"). ', $extensionName, $loadingFilePath), |
| 39 | + default => sprintf('There is no extension able to load the configuration for "%s". ', $extensionName), |
| 40 | + }; |
| 41 | + |
| 42 | + $message .= sprintf('Looked for namespace "%s", found "%s".', $namespaceOrAlias, $foundExtensionNamespaces ? implode('", "', $foundExtensionNamespaces) : 'none'); |
| 43 | + |
| 44 | + return $message; |
| 45 | + } |
| 46 | +} |
0 commit comments