Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af4a0eb

Browse files
Add similar messages
1 parent 3a85f02 commit af4a0eb

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Symfony/Bridge/Twig/UndefinedCallableHandler.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,21 @@ class UndefinedCallableHandler
5656
'workflow_marked_places' => 'workflow',
5757
);
5858

59+
private static $fullStackEnable = array(
60+
'form' => 'enable "framework.form"',
61+
'security-core' => 'add the "SecurityBundle"',
62+
'security-http' => 'add the "SecurityBundle"',
63+
'web-link' => 'enable "framework.web_link"',
64+
'workflow' => 'enable "framework.workflows"',
65+
);
66+
5967
public static function onUndefinedFilter($name)
6068
{
6169
if (!isset(self::$filterComponents[$name])) {
6270
return false;
6371
}
6472

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));
73+
self::onUndefined($name, 'filter', self::$filterComponents[$name]);
6774
}
6875

6976
public static function onUndefinedFunction($name)
@@ -72,10 +79,15 @@ public static function onUndefinedFunction($name)
7279
return false;
7380
}
7481

75-
if (\class_exists(FullStack::class) && 'web-link' === self::$functionComponents[$name]) {
76-
throw new SyntaxError(sprintf('Did you forget to enable "framework.web_link"? Unknown function "%s".', self::$functionComponents[$name], $name));
82+
self::onUndefined($name, 'function', self::$functionComponents[$name]);
83+
}
84+
85+
private static function onUndefined($name, $type, $component)
86+
{
87+
if (\class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
88+
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name));
7789
}
7890

79-
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown function "%s".', self::$functionComponents[$name], $name));
91+
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name));
8092
}
8193
}

0 commit comments

Comments
 (0)