public function translateAction(Request $request)
 {
     $lang = $request->route->getParam('lang');
     $validLangs = ['es', 'fr'];
     $response = new Response();
     $response->setContentType('text/html; charset=utf-8');
     $smartyTemplating = $this->getServicesContainer()->getService('smarty-templating');
     $smartyTemplating->setTemplate('translations.tpl');
     $smartyTemplating->setVariable('lang', $lang);
     if (in_array($lang, $validLangs)) {
         $translator = $this->getServicesContainer()->getService('translator');
         $translator->setTranslationsFile("../app/translations/translations_{$lang}.yml");
         $translations = ['Hello World!' => $translator->translate('Hello World!'), 'Wellcome to the Night Standard Edition application' => $translator->translate('Wellcome to the Night Standard Edition application')];
         $smartyTemplating->setVariable('translations', $translations);
         $html = $smartyTemplating->render();
         $response->setContent($html);
         $response->setResponseStatus(200, 'OK');
         return $response;
     }
     $smartyTemplating->setVariable('validLangs', $validLangs);
     $html = $smartyTemplating->render();
     $response->setContent($html);
     $response->setResponseStatus(404, 'Not Found');
     return $response;
 }
 public function homeAction()
 {
     $templating = $this->getServicesContainer()->getService('smarty-templating');
     $templating->setTemplate('home.tpl');
     $html = $templating->render();
     $response = new Response();
     $response->setContentType('text\\html');
     $response->setResponseStatus(200, 'OK');
     $response->setContent($html);
     return $response;
 }
 public function listCitiesFromCountryCodeAction(Request $request)
 {
     $countryCode = $request->route->getParam('countryCode');
     $pdoRepository = $this->getServicesContainer()->getService('pdo-repository');
     $statement = "SELECT Name, District, Population FROM City WHERE City.CountryCode = :countryCode ORDER BY City.Name;";
     $pdoRepository->setStatement($statement);
     $pdoRepository->setParam(':countryCode', $countryCode, PDORepository::PARAM_STR);
     $pdoRepository->executeStatement();
     $cities = $pdoRepository->getResults();
     $twigTemplating = $this->getServicesContainer()->getService('twig-templating');
     $twigTemplating->setTemplate('listCities.twig');
     $twigTemplating->setVariable('countryCode', $countryCode);
     $twigTemplating->setVariable('citiesList', $cities);
     $html = $twigTemplating->render();
     $response = new Response();
     $response->setResponseStatus(200, 'OK');
     $response->setContentType('text/html; charset=utf-8');
     $response->setContent($html);
     return $response;
 }