Skip to content

Commit 4794c3c

Browse files
committed
Merge branch '4.0' into 4.1
* 4.0: [TwigBundle][DX] Only add the Twig WebLinkExtension if the WebLink component is enabled Add note about changed form processing when using PUT requests [SecurityBundle] Dont throw if "security.http_utils" is not found [Di] Fix undefined variable found by Php Inspections (EA Ultimate) [DI] Cleanup unused service_subscriber.locator tag [DI] Resolve env placeholder in logs The debug class loader is always loaded by Debug::enable(). [Intl] Update ICU data to 62.1
2 parents 2d73281 + cac080f commit 4794c3c

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

UndefinedCallableHandler.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Twig;
1313

14+
use Symfony\Bundle\FullStack;
1415
use Twig\Error\SyntaxError;
1516

1617
/**
@@ -56,14 +57,21 @@ class UndefinedCallableHandler
5657
'workflow_marked_places' => 'workflow',
5758
);
5859

60+
private static $fullStackEnable = array(
61+
'form' => 'enable "framework.form"',
62+
'security-core' => 'add the "SecurityBundle"',
63+
'security-http' => 'add the "SecurityBundle"',
64+
'web-link' => 'enable "framework.web_link"',
65+
'workflow' => 'enable "framework.workflows"',
66+
);
67+
5968
public static function onUndefinedFilter($name)
6069
{
6170
if (!isset(self::$filterComponents[$name])) {
6271
return false;
6372
}
6473

65-
// Twig will append the source context to the message, so that it will end up being like "[...] Unknown filter "%s" in foo.html.twig on line 123."
66-
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown filter "%s".', self::$filterComponents[$name], $name));
74+
self::onUndefined($name, 'filter', self::$filterComponents[$name]);
6775
}
6876

6977
public static function onUndefinedFunction($name)
@@ -72,6 +80,15 @@ public static function onUndefinedFunction($name)
7280
return false;
7381
}
7482

75-
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown function "%s".', self::$functionComponents[$name], $name));
83+
self::onUndefined($name, 'function', self::$functionComponents[$name]);
84+
}
85+
86+
private static function onUndefined($name, $type, $component)
87+
{
88+
if (\class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
89+
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name));
90+
}
91+
92+
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name));
7693
}
7794
}

0 commit comments

Comments
 (0)