public function findByName($name, $limit = null)
 {
     $queryOptions = new QueryOptionBag();
     if ($limit) {
         $queryOptions->add(QueryOption::LIMIT, $limit);
     }
     return $this->doctrine->getRepository('TermBundle:Term')->findByName($name, $queryOptions);
 }
 /**
  * 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'));
 }