In my Symfony project I have various twig view's with same properties as the main twig layout has some and also block twig content for every view has some new ones.
Like:
private function generateView($page, $type, $user, $pageCount = 20){ $mainImgUrl = $this->imageService->getAvatarPath($user->getId()); $places = $this->entityManager->getRepository(Place::class)->getPage($type, $page, $pageCount); $menu = $this->builder->getMenuThings(); return $this->render('places.html.twig', ['type' => $type,'mainImgUrl' => $mainImgUrl,'places' => $places['data'],'fullName' => $user->getFirstName().''.$user->getLastName(),'menu' => $menu,'contentTitle' => $title,'contentDescription' => '','totalItems' => $p['totalItems'],'pageCount' => $workspaces['pagesCount'],'pageSize' => $pageSize,'currentPage' => $page ]);}
So, half of these belong to main twig view and just a few in block twig view. Whenever I am generating new twig view I have to include all of them which is probably harder way to do it.
I want to ask if anyone has any suggestions how can I, for example, make a 'helper' method and call it in every new twig view so I escape including all of these in every new method I write.
Thanks