E
E
Eobard Thawne2019-08-05 08:32:00
symfony
Eobard Thawne, 2019-08-05 08:32:00

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
        ]);
    }

How do I get the $builder variable in the second function.
/**
     * @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');
    }

How can I do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
postgresdev, 2019-09-14
@postgresdev

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 question

Ask a Question

731 491 924 answers to any question