11
11
12
12
namespace Symfony \Bridge \Twig ;
13
13
14
+ use Symfony \Bundle \FullStack ;
14
15
use Twig \Error \SyntaxError ;
15
16
16
17
/**
@@ -55,14 +56,21 @@ class UndefinedCallableHandler
55
56
'workflow_marked_places ' => 'workflow ' ,
56
57
);
57
58
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
+
58
67
public static function onUndefinedFilter ($ name )
59
68
{
60
69
if (!isset (self ::$ filterComponents [$ name ])) {
61
70
return false ;
62
71
}
63
72
64
- // 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."
65
- 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 ]);
66
74
}
67
75
68
76
public static function onUndefinedFunction ($ name )
@@ -71,6 +79,15 @@ public static function onUndefinedFunction($name)
71
79
return false ;
72
80
}
73
81
74
- throw new SyntaxError (sprintf ('Did you forget to run "composer require symfony/%s"? 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 ));
89
+ }
90
+
91
+ throw new SyntaxError (sprintf ('Did you forget to run "composer require symfony/%s"? Unknown %s "%s". ' , $ component , $ type , $ name ));
75
92
}
76
93
}
0 commit comments