/** * @param string $ticker * * @Route("/stocks/{ticker}", name="stock_page") * @Method("GET") * @return Response */ public function showAction($ticker) { $company = $this->getDoctrine()->getRepository('AppBundle:StockCompany')->findOneBy(['ticker' => $ticker]); if (!$company) { return $this->createNotFoundException(); } $companyData = $this->stockDataProvider->getCompany($ticker); return $this->render('stocks/show.html.twig', ['company' => $company, 'companyData' => $companyData]); }
/** * @Route("/", name="homepage") */ public function indexAction(Request $request) { $companies = $this->getDoctrine()->getRepository('AppBundle:StockCompany')->findAll(); $tickers = array_map(function ($company) { return $company->ticker; }, $companies); $companiesData = $this->stockDataProvider->getCompanies($tickers); return $this->render('default/index.html.twig', ['companies' => $companies, 'companiesData' => $companiesData]); }