public function listCityTreatmentAction(Request $request) { $parameters = $request->attributes->get('_route_params'); $em = $this->getDoctrine()->getManager(); if (!($city = $em->getRepository('HelperBundle:City')->find(isset($parameters['cityId']) ? $parameters['cityId'] : $parameters['city']))) { throw new NotFoundHttpException(); } if (!($treatment = $em->getRepository('TreatmentBundle:Treatment')->find(isset($parameters['treatmentId']) ? $parameters['treatmentId'] : $parameters['treatment']))) { throw new NotFoundHttpException(); } //$pagerAdapter = new ArrayAdapter($em->getRepository('InstitutionBundle:InstitutionMedicalCenter')->getMedicalCentersByTreatmentAndCity($treatment, $city)); $pagerAdapter = new ArrayAdapter($em->getRepository('TermBundle:SearchTerm')->findByFilters(array($treatment, $city))); $pager = new Pager($pagerAdapter, array('page' => $request->get('page'), 'limit' => $this->resultsPerPage)); // set total results for page metas $request->attributes->set('pageMetaVariables', array(PageMetaConfigurationService::CLINIC_RESULTS_COUNT_VARIABLE => $pager->getTotalResults())); $request->attributes->set('searchObjects', array(SearchUrlGenerator::SEARCH_URL_PARAMETER_SPECIALIZATION => $treatment->getSpecialization(), SearchUrlGenerator::SEARCH_URL_PARAMETER_TREATMENT => $treatment, SearchUrlGenerator::SEARCH_URL_PARAMETER_COUNTRY => $city->getCountry(), SearchUrlGenerator::SEARCH_URL_PARAMETER_CITY => $city)); $this->setBreadcrumbRequestAttributes($request, array('country' => $city->getCountry(), 'city' => $city, 'specialization' => $treatment->getSpecialization(), 'treatment' => $treatment)); $response = $this->render('SearchBundle:Frontend:resultsCombination.html.twig', array('searchResults' => $pager, 'searchLabel' => array('treatment' => $treatment->getName(), 'destination' => $city->getName() . ', ' . $city->getCountry()->getName()), 'treatment' => $treatment, 'city' => $city, 'includedNarrowSearchWidgets' => array(), 'featuredClinicParams' => array('cityId' => $city->getId(), 'treatmentId' => $treatment->getId()))); $response->headers->setCookie($this->buildCookie(array('countryId' => $city->getCountry()->getId(), 'cityId' => $city->getId(), 'specializationId' => $treatment->getSpecialization()->getId(), 'treatmentId' => $treatment->getId()))); return $this->setResponseHeaders($response); }
public function searchResultsTreatmentsAction(Request $request) { $searchTerms = json_decode($request->getSession()->remove('search_terms'), true); if (!($specialization = $this->getDoctrine()->getRepository('TreatmentBundle:Specialization')->getSpecialization(isset($searchTerms['specializationId']) ? $searchTerms['specializationId'] : $request->get('specialization'), true))) { throw new NotFoundHttpException(); } if (!($treatment = $this->getDoctrine()->getRepository('TreatmentBundle:Treatment')->getTreatment(isset($searchTerms['treatmentId']) ? $searchTerms['treatmentId'] : $request->get('treatment')))) { throw new NotFoundHttpException(); } //TODO: verify if we still need this snippet if (isset($searchTerms['termId'])) { $termId = $searchTerms['termId']; } else { $term = $this->get('services.search')->getTerm($request->get('treatment'), array('column' => 'slug')); $termId = $term['id']; } //TODO: This is temporary; use OrmAdapter $adapter = new ArrayAdapter($this->get('services.search')->searchByTreatment($treatment)); $pager = new Pager($adapter, array('page' => $request->get('page'), 'limit' => $this->resultsPerPage)); $parameters = array('searchResults' => $pager, 'searchLabel' => isset($searchTerms['treatmentLabel']) ? $searchTerms['treatmentLabel'] : $specialization->getName() . ' - ' . $treatment->getName(), 'routeName' => 'frontend_search_results_treatments', 'paginationParameters' => array('specialization' => $specialization->getSlug(), 'treatment' => $treatment->getSlug()), 'treatmentId' => $termId, 'treatment' => $treatment, 'includedNarrowSearchWidgets' => array('destinations'), 'narrowSearchParameters' => $treatment ? array(SearchParameterBag::FILTER_SPECIALIZATION => $specialization->getId(), SearchParameterBag::FILTER_TREATMENT => $treatment->getId()) : array(), 'featuredClinicParams' => array('treatmentId' => $treatment->getId())); // set total results for page metas $request->attributes->set('pageMetaVariables', array(PageMetaConfigurationService::CLINIC_RESULTS_COUNT_VARIABLE => $pager->getTotalResults())); $request->attributes->set('searchObjects', array(SearchUrlGenerator::SEARCH_URL_PARAMETER_SPECIALIZATION => $specialization, SearchUrlGenerator::SEARCH_URL_PARAMETER_TREATMENT => $treatment)); $this->setBreadcrumbRequestAttributes($request, array('specialization' => $specialization, 'treatment' => $treatment)); return $this->setResponseHeaders($this->render('SearchBundle:Frontend:resultsTreatments.html.twig', $parameters)); }