Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[TwigBridge] Addencore_entry_*_tags() to UndefinedCallableHandler, as no-op#41205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:5.4fromnicolas-grekas:twig-encore
Jun 23, 2021
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletionssrc/Symfony/Bridge/Twig/UndefinedCallableHandler.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,8 @@

use Symfony\Bundle\FullStack;
use Twig\Error\SyntaxError;
use Twig\TwigFilter;
use Twig\TwigFunction;

/**
* @internal
Expand All@@ -30,6 +32,8 @@ class UndefinedCallableHandler
'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',
Expand DownExpand Up@@ -64,34 +68,40 @@ class UndefinedCallableHandler
'workflow' => 'enable "framework.workflows"',
];

public static function onUndefinedFilter(string $name): bool
/**
* @return TwigFilter|false
*/
public static function onUndefinedFilter(string $name)
{
if (!isset(self::FILTER_COMPONENTS[$name])) {
return false;
}

self::onUndefined($name, 'filter', self::FILTER_COMPONENTS[$name]);

return true;
throw new SyntaxError(self::onUndefined($name, 'filter', self::FILTER_COMPONENTS[$name]));
}

public static function onUndefinedFunction(string $name): bool
/**
* @return TwigFunction|false
*/
public static function onUndefinedFunction(string $name)
{
if (!isset(self::FUNCTION_COMPONENTS[$name])) {
return false;
}

self::onUndefined($name, 'function', self::FUNCTION_COMPONENTS[$name]);
if ('webpack-encore-bundle' === self::FUNCTION_COMPONENTS[$name]) {
return new TwigFunction($name, static function () { return ''; });
}

return true;
throw new SyntaxError(self::onUndefined($name, 'function', self::FUNCTION_COMPONENTS[$name]));
}

private static function onUndefined(string $name, string $type, string $component)
private static function onUndefined(string $name, string $type, string $component): string
{
if (class_exists(FullStack::class) && isset(self::FULL_STACK_ENABLE[$component])) {
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::FULL_STACK_ENABLE[$component], $type, $name));
returnsprintf('Did you forget to %s? Unknown %s "%s".', self::FULL_STACK_ENABLE[$component], $type, $name);
}

throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name));
returnsprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name);
}
}

[8]ページ先頭

©2009-2025 Movatter.jp