acl_gen = $acl_gen; } public function getAll(EntityManagerInterface $em) { // get all hub data order by name $this->denyAccessUnlessGranted('hub.list', null, 'No access.'); $results = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']); $hubs = []; foreach($results as $res) { $hub_id = $res->getId(); $hub_name = $res->getName(); $hub_address = $res->getAddress(); $hub_branch_code = $res->getBranchCode(); $hubs[$hub_id] = [ 'id' => $hub_id, 'name' => $hub_name, 'address' => $hub_address, 'branch_code' => $hub_branch_code, ]; } $data = [ 'hubs' => $hubs, ]; return new APIResponse(true, 'Hubs loaded.', $data); } }