public function build_frontend_meta_configuration(Request $request)
 {
     $url = $request->getPathInfo();
     $metaConfig = $this->pageMetaConfigurationService->findOneByUrl($url);
     // we have no saved configuration yet
     if (!$metaConfig) {
         // TODO: this is just a temporary approach
         // check if searchObjects attributes parameter has been set from the main controller
         if ($request->attributes->has('searchObjects')) {
             // this is a search results page
             $metaConfig = $this->pageMetaConfigurationService->buildFromSearchObjects($request->attributes->get('searchObjects'));
             $metaConfig->setUrl($url);
             // save this new config
             $this->pageMetaConfigurationService->save($metaConfig);
         } elseif (($institution = $request->attributes->get('institution', null)) && PageMetaConfiguration::PAGE_TYPE_INSTITUTION == $request->attributes->get('pageMetaContext', PageMetaConfiguration::PAGE_TYPE_STATIC)) {
             $metaConfig = $this->pageMetaConfigurationService->buildForInstitutionPage($institution);
             $metaConfig->setUrl($url);
             // save this new config
             $this->pageMetaConfigurationService->save($metaConfig);
         } elseif (($institutionMedicalCenter = $request->attributes->get('institutionMedicalCenter', null)) && $institutionMedicalCenter instanceof InstitutionMedicalCenter && PageMetaConfiguration::PAGE_TYPE_INSTITUTION_MEDICAL_CENTER == $request->attributes->get('pageMetaContext', PageMetaConfiguration::PAGE_TYPE_STATIC)) {
             $metaConfig = $this->pageMetaConfigurationService->buildForInstitutionMedicalCenterPage($institutionMedicalCenter);
             $metaConfig->setUrl($url);
             // save this new config
             $this->pageMetaConfigurationService->save($metaConfig);
         } else {
             // we don't have dynamic ways for adding other pages
             $metaConfig = new PageMetaConfiguration();
             // set to default metas
             $metaConfig->setTitle($this->siteName . ' - Global Medical Tourism Directory');
             $metaConfig->setDescription('');
             $metaConfig->setKeywords('');
         }
     }
     $pageMetaVariables = $request->attributes->get('pageMetaVariables', array());
     // replace variables in description
     $metaConfig->setDescription($this->_supplyPatternVariables($metaConfig->getDescription(), $pageMetaVariables));
     // replace variables in keywords
     $metaConfig->setKeywords($this->_supplyPatternVariables($metaConfig->getKeywords(), $pageMetaVariables));
     return $metaConfig;
 }
 /**
  * Create a PageMetaConfiguration for clinic page
  * 
  * @param InstitutionMedicalCenter $institutionMedicalCenter
  * @return \HealthCareAbroad\HelperBundle\Entity\PageMetaConfiguration
  */
 public function buildForInstitutionMedicalCenterPage(InstitutionMedicalCenter $institutionMedicalCenter)
 {
     $institution = $institutionMedicalCenter->getInstitution();
     $location = ($institution->getCity() ? $institution->getCity() . ', ' : '') . $institution->getCountry();
     $metaConfig = new PageMetaConfiguration();
     $metaConfig->setTitle("{$institutionMedicalCenter->getName()} - {$institution->getName()} {$location} - " . $this->siteName);
     $metaConfig->setDescription("{$institutionMedicalCenter->getName()} at {$institution->getName()} offers treatments in {" . PageMetaConfigurationService::SPECIALIZATIONS_LIST_VARIABLE . "} in {$location}. Get details at " . $this->siteName);
     $metaConfig->setKeywords("{$institution->getName()}, {$institutionMedicalCenter->getName()}, {$location}, {" . PageMetaConfigurationService::SPECIALIZATIONS_LIST_VARIABLE . "}, medical tourism, Doctor, Dentist");
     $metaConfig->setPageType(PageMetaConfiguration::PAGE_TYPE_INSTITUTION_MEDICAL_CENTER);
     return $metaConfig;
 }