I'm looking for the recommended way to pass a same array to the template of multiple routes.
Exemple:
$app->group('/blabla', function (RouteCollectorProxy $group) {
$group->get('', function (Request $request, Response $response, $args) {
return $this->get('view')->render($response, 'first-route.html.twig', [
'var1' => "wiggle",
'var2' => "lightSpeedIn",
'var3' => 'fadeInDown',
'var4' => 'wiggle',
'var5' => "wobble",
]);
})->setName('portfolio-ancien');
$group->get('/hello', function (Request $request, Response $response, $args) {
return $this->get('view')->render($response, 'seconde-route.html.twig', [
'var1' => "wiggle",
'var2' => "lightSpeedIn",
'var3' => 'fadeInDown',
'var4' => 'wiggle',
'var5' => "wobble",
]);
})->setName('portfolio-ancien-quiSuisJe');
});
My array parameters is the same, how can I pass it to the template without repeated it twice ?