public static function groupGlobalAwardPropertiesByType(array $properties)
 {
     $awardTypes = GlobalAwardTypes::getTypes();
     $globalAwards = \array_flip(GlobalAwardTypes::getTypeKeys());
     // initialize holder for awards
     foreach ($globalAwards as $k => $v) {
         $globalAwards[$k] = array();
     }
     foreach ($properties as $_property) {
         $_globalAward = $_property->getValueObject();
         $globalAwards[\strtolower($awardTypes[$_globalAward->getType()])][] = $_property;
     }
     return $globalAwards;
 }
 /**
  * Load available global awards of an institution. Used in autocomplete fields
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function ajaxMedicalCenterGlobalAwardSourceAction(Request $request)
 {
     $term = \trim($request->get('term', ''));
     $type = $request->get('type', null);
     $types = \array_flip(GlobalAwardTypes::getTypeKeys());
     $type = \array_key_exists($type, $types) ? $types[$type] : 0;
     $output = array();
     $options = new QueryOptionBag();
     $options->add('globalAward.name', $term);
     if ($type) {
         $options->add('globalAward.type', $type);
     }
     $awards = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionMedicalCenterProperty')->getAvailableGlobalAwardsOfInstitutionMedicalCenter($this->institutionMedicalCenter, $options);
     foreach ($awards as $_award) {
         $output[] = array('id' => $_award->getId(), 'label' => $_award->getName(), 'awardingBody' => $_award->getAwardingBody()->getName());
     }
     return new Response(\json_encode($output), 200, array('content-type' => 'application/json'));
 }
 /**
  * @deprecated ?
  * @param InstitutionMedicalCenter $institutionMedicalCenter
  */
 public function getGroupedMedicalCenterGlobalAwards(InstitutionMedicalCenter $institutionMedicalCenter)
 {
     $awardTypes = GlobalAwardTypes::getTypes();
     $globalAwards = \array_flip(GlobalAwardTypes::getTypeKeys());
     // initialize holder for awards
     foreach ($globalAwards as $k => $v) {
         $globalAwards[$k] = array();
     }
     $imcProperties = $this->institutionMedicalCenterPropertyService->getGlobalAwardPropertiesByInstitutionMedicalCenter($institutionMedicalCenter);
     foreach ($imcProperties as $imcp_arr) {
         if (!empty($imcp_arr)) {
             foreach ($imcp_arr as $imcp) {
                 $_globalAward = $imcp->getValueObject();
                 $globalAwards[\strtolower($awardTypes[$_globalAward->getType()])][] = $imcp;
             }
         }
     }
     //         foreach ($this->getMedicalCenterGlobalAwards($institutionMedicalCenter) as $_globalAward) {
     //             $globalAwards[\strtolower($awardTypes[$_globalAward->getType()])][] = array(
     //                 'global_award' => $_globalAward,
     //             );
     //         }
     return $globalAwards;
 }