How to inject global variables into all templates?
问题 In my twig template there are some variables that are required on each page like userName , userId or userImage . What is the best way to inject them into the template? I already read the article How to Inject Variables into all Templates but how could I write a variable (e.g. current user) into the config/packages/twig.php file? Right now there is code like this in every controller: return $this->render('admin/users/index.html.twig', [ "allUsers" => $allUsers, "pageTitle" =>