@@ -56,14 +56,21 @@ class UndefinedCallableHandler
56
56
'workflow_marked_places ' => 'workflow ' ,
57
57
);
58
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
+
59
67
public static function onUndefinedFilter ($ name )
60
68
{
61
69
if (!isset (self ::$ filterComponents [$ name ])) {
62
70
return false ;
63
71
}
64
72
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 ]);
67
74
}
68
75
69
76
public static function onUndefinedFunction ($ name )
@@ -72,10 +79,15 @@ public static function onUndefinedFunction($name)
72
79
return false ;
73
80
}
74
81
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 ));
77
89
}
78
90
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 ));
80
92
}
81
93
}
0 commit comments