Answer the question
In order to leave comments, you need to log in
How to get the value of a variable from another function?
Hello everyone, how to pass variables between functions in Symfony. Here is an example...
/**
* @Route("/details/{builderId}", methods={"GET","POST"}, name="builder")
*/
public function builder($builderId, Request $request, DataService $dataService, BuilderService $builderService){
$builder = $builderService->getBuilder($builderId);
return $this->render('builders/details.html.twig', [
'builder' => $builder['outcome'] == 'success' ? $builder['data'] : array(),
'builderId' => $builderId
]);
}
/**
* @Route("/details/building/{buildingId}", methods={"GET","POST"}, name="building")
*/
public function building($buildingId, Request $request, DataService $dataService, BuilderService $builderService){
return $this->render('builders/detailsBuilding.html.twig');
}
Answer the question
In order to leave comments, you need to log in
Perhaps you did not register the service in the service container or did not specify true outsourcing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question