@@ -33,18 +33,19 @@ public function __construct(Environment $twig = null)
3333 /**
3434 * Renders a template.
3535 *
36- * @param string $template The template name
37- * @param int|null $maxAge Max age for client caching
38- * @param int|null $sharedAge Max age for shared (proxy) caching
39- * @param bool|null $private Whether or not caching should apply for client caches only
36+ * @param string $template The template name
37+ * @param int|null $maxAge Max age for client caching
38+ * @param int|null $sharedAge Max age for shared (proxy) caching
39+ * @param bool|null $private Whether or not caching should apply for client caches only
40+ * @param array $context The context (arguments) of the template
4041 */
41- public function templateAction (string $ template , int $ maxAge = null , int $ sharedAge = null , bool $ private = null ): Response
42+ public function templateAction (string $ template , int $ maxAge = null , int $ sharedAge = null , bool $ private = null , array $ context = [] ): Response
4243 {
4344 if (null === $ this ->twig ) {
4445 throw new \LogicException ('You can not use the TemplateController if the Twig Bundle is not available. ' );
4546 }
4647
47- $ response = new Response ($ this ->twig ->render ($ template ));
48+ $ response = new Response ($ this ->twig ->render ($ template, $ context ));
4849
4950 if ($ maxAge ) {
5051 $ response ->setMaxAge ($ maxAge );
@@ -63,8 +64,8 @@ public function templateAction(string $template, int $maxAge = null, int $shared
6364 return $ response ;
6465 }
6566
66- public function __invoke (string $ template , int $ maxAge = null , int $ sharedAge = null , bool $ private = null ): Response
67+ public function __invoke (string $ template , int $ maxAge = null , int $ sharedAge = null , bool $ private = null , array $ context = [] ): Response
6768 {
68- return $ this ->templateAction ($ template , $ maxAge , $ sharedAge , $ private );
69+ return $ this ->templateAction ($ template , $ maxAge , $ sharedAge , $ private, $ context );
6970 }
7071}
0 commit comments