mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -13,28 +13,32 @@ namespace Symfony\Bridge\Twig;
|
||||
|
||||
use Symfony\Bundle\FullStack;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class UndefinedCallableHandler
|
||||
{
|
||||
private static $filterComponents = [
|
||||
private const FILTER_COMPONENTS = [
|
||||
'humanize' => 'form',
|
||||
'trans' => 'translation',
|
||||
'transchoice' => 'translation',
|
||||
'yaml_encode' => 'yaml',
|
||||
'yaml_dump' => 'yaml',
|
||||
];
|
||||
|
||||
private static $functionComponents = [
|
||||
private const FUNCTION_COMPONENTS = [
|
||||
'asset' => 'asset',
|
||||
'asset_version' => 'asset',
|
||||
'dump' => 'debug-bundle',
|
||||
'encore_entry_link_tags' => 'webpack-encore-bundle',
|
||||
'encore_entry_script_tags' => 'webpack-encore-bundle',
|
||||
'expression' => 'expression-language',
|
||||
'form_widget' => 'form',
|
||||
'form_errors' => 'form',
|
||||
'form_label' => 'form',
|
||||
'form_help' => 'form',
|
||||
'form_row' => 'form',
|
||||
'form_rest' => 'form',
|
||||
'form' => 'form',
|
||||
@@ -56,7 +60,7 @@ class UndefinedCallableHandler
|
||||
'workflow_marked_places' => 'workflow',
|
||||
];
|
||||
|
||||
private static $fullStackEnable = [
|
||||
private const FULL_STACK_ENABLE = [
|
||||
'form' => 'enable "framework.form"',
|
||||
'security-core' => 'add the "SecurityBundle"',
|
||||
'security-http' => 'add the "SecurityBundle"',
|
||||
@@ -64,34 +68,40 @@ class UndefinedCallableHandler
|
||||
'workflow' => 'enable "framework.workflows"',
|
||||
];
|
||||
|
||||
public static function onUndefinedFilter($name)
|
||||
/**
|
||||
* @return TwigFilter|false
|
||||
*/
|
||||
public static function onUndefinedFilter(string $name)
|
||||
{
|
||||
if (!isset(self::$filterComponents[$name])) {
|
||||
if (!isset(self::FILTER_COMPONENTS[$name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::onUndefined($name, 'filter', self::$filterComponents[$name]);
|
||||
|
||||
return true;
|
||||
throw new SyntaxError(self::onUndefined($name, 'filter', self::FILTER_COMPONENTS[$name]));
|
||||
}
|
||||
|
||||
public static function onUndefinedFunction($name)
|
||||
/**
|
||||
* @return TwigFunction|false
|
||||
*/
|
||||
public static function onUndefinedFunction(string $name)
|
||||
{
|
||||
if (!isset(self::$functionComponents[$name])) {
|
||||
if (!isset(self::FUNCTION_COMPONENTS[$name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::onUndefined($name, 'function', self::$functionComponents[$name]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function onUndefined($name, $type, $component)
|
||||
{
|
||||
if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
|
||||
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name));
|
||||
if ('webpack-encore-bundle' === self::FUNCTION_COMPONENTS[$name]) {
|
||||
return new TwigFunction($name, static function () { return ''; });
|
||||
}
|
||||
|
||||
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name));
|
||||
throw new SyntaxError(self::onUndefined($name, 'function', self::FUNCTION_COMPONENTS[$name]));
|
||||
}
|
||||
|
||||
private static function onUndefined(string $name, string $type, string $component): string
|
||||
{
|
||||
if (class_exists(FullStack::class) && isset(self::FULL_STACK_ENABLE[$component])) {
|
||||
return sprintf('Did you forget to %s? Unknown %s "%s".', self::FULL_STACK_ENABLE[$component], $type, $name);
|
||||
}
|
||||
|
||||
return sprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user