public function profileAction(Request $request) { $start = \microtime(true); $this->apiInstitutionMedicalCenterService = $this->get('services.api.institutionMedicalCenter'); $slug = $request->get('imcSlug', null); $institutionMedicalCenterId = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionMedicalCenter')->getInstitutionMedicalCenterIdBySlug($slug); if (!$institutionMedicalCenterId) { throw $this->createNotFoundException('Invalid clinic.'); } $memcacheKey = FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($institutionMedicalCenterId); $memcacheService = $this->get('services.memcache'); $cachedData = $memcacheService->get($memcacheKey); if (!$cachedData) { $this->institutionMedicalCenter = $this->apiInstitutionMedicalCenterService->getInstitutionMedicalCenterPublicDataById($institutionMedicalCenterId); if (!$this->institutionMedicalCenter) { throw $this->createNotFoundException('Invalid medical center'); } $this->institution = $this->institutionMedicalCenter['institution']; if ($this->get('services.api.institution')->isSingleCenterInstitutionType($this->institution)) { // redirect to hospital page } // build optional data, according to paying client rules $this->apiInstitutionMedicalCenterService->buildBusinessHours($this->institutionMedicalCenter)->buildDoctors($this->institutionMedicalCenter)->buildGlobalAwards($this->institutionMedicalCenter)->buildOfferedServices($this->institutionMedicalCenter)->buildInstitutionSpecializations($this->institutionMedicalCenter)->buildLogoSource($this->institutionMedicalCenter, ImageSizes::MEDIUM)->buildFeaturedMediaSource($this->institutionMedicalCenter)->buildMediaGallery($this->institutionMedicalCenter)->buildContactDetails($this->institutionMedicalCenter)->buildExternalSites($this->institutionMedicalCenter); $specializationsList = $this->apiInstitutionMedicalCenterService->listActiveSpecializations($this->institutionMedicalCenter); $this->institutionMedicalCenter['specializationsList'] = $specializationsList; // cache this processed data $memcacheService->set($memcacheKey, $this->institutionMedicalCenter); } else { $this->institutionMedicalCenter = $cachedData; $this->institution = $this->institutionMedicalCenter['institution']; $specializationsList = $this->institutionMedicalCenter['specializationsList']; } $params = array('awards' => $this->institutionMedicalCenter['globalAwards'], 'services' => $this->institutionMedicalCenter['offeredServices'], 'institutionMedicalCenter' => $this->institutionMedicalCenter, 'institution' => $this->institution, 'form' => $this->createForm(new InstitutionInquiryFormType(), new InstitutionInquiry())->createView(), 'formId' => 'imc_inquiry_form'); // set request variables to be used by page meta components $this->getRequest()->attributes->add(array('institutionMedicalCenter' => $this->institutionMedicalCenter, 'pageMetaContext' => PageMetaConfiguration::PAGE_TYPE_INSTITUTION_MEDICAL_CENTER, 'pageMetaVariables' => array(PageMetaConfigurationService::SPECIALIZATIONS_COUNT_VARIABLE => \count($specializationsList), PageMetaConfigurationService::SPECIALIZATIONS_LIST_VARIABLE => \implode(', ', \array_slice($specializationsList, 0, 10, true))))); $content = $this->render('FrontendBundle:InstitutionMedicalCenter:profile.html.twig', $params); //$end = \microtime(true); $diff = $end-$start; echo "{$diff}s"; exit; return $this->setResponseHeaders($content); }
private function processMultipleCenterInstitution() { // build doctors data $this->apiInstitutionService->buildDoctors($this->institution); // Hesitant on modifying the twig extension since it is used in many contexts foreach ($this->institution['institutionMedicalCenters'] as $key => &$imcData) { $this->apiInstitutionMedicalCenterService->buildLogoSource($imcData, ImageSizes::MINI, InstitutionMedicalCenterApiService::CONTEXT_HOSPITAL_CLINICS_LIST); // flatten specializations list for displaying list // do this here so we will have no processing in twig template and so this will be cached $imcData['specializationsList'] = array(); foreach ($imcData['institutionSpecializations'] as $instSpecialization) { // we always assume this since this is eagerly loaded in buildInstitutionSpecializations $imcData['specializationsList'][$instSpecialization['specialization']['id']] = $instSpecialization['specialization']['name']; } } }