/** * * * @param array $institutionMedicalCenter * @return \HealthCareAbroad\ApiBundle\Services\InstitutionMedicalCenterApiService */ public function buildContactDetails(&$institutionMedicalCenter, $context = InstitutionMedicalCenterApiService::CONTEXT_FULL_PAGE_VIEW) { $institutionMedicalCenter['mainContactNumber'] = null; $canDisplayContactDetails = PayingStatus::FREE_LISTING != $institutionMedicalCenter['payingClient']; if ($canDisplayContactDetails) { // add a string representation for each contactDetail $hasSetMainContact = false; foreach ($institutionMedicalCenter['contactDetails'] as &$contactDetail) { $contactDetail['__toString'] = $this->contactDetailService->contactDetailToString($contactDetail); if (!$hasSetMainContact) { $institutionMedicalCenter['mainContactNumber'] = $contactDetail; $hasSetMainContact = true; } } } else { // not yet used, but could be helpful if (self::CONTEXT_FULL_API != $context) { // TODO: Note to self: do we really have to clear this? $institutionMedicalCenter['contactDetails'] = array(); } } return $this; }
/** * Build contact details data of institution, also add a mainContactNumber property * * @param array $institution * @param int $context * @return \HealthCareAbroad\ApiBundle\Services\InstitutionApiService */ public function buildContactDetails(&$institution, $context = InstitutionApiService::CONTEXT_FULL_PAGE_VIEW) { $institution['mainContactNumber'] = null; $canDisplay = $institution['payingClient'] != 0; if (InstitutionApiService::CONTEXT_FULL_API != $context && !$canDisplay) { $institution['contactDetails'] = array(); } else { // add a string representation for each contactDetail $hasSetMainContact = false; foreach ($institution['contactDetails'] as &$contactDetail) { $contactDetail['__toString'] = $this->contactDetailService->contactDetailToString($contactDetail); if (!$hasSetMainContact) { $institution['mainContactNumber'] = $contactDetail; $hasSetMainContact = true; } } } return $this; }