Ejemplo n.º 1
0
 /**
  * @param string $term
  * @return string
  */
 public function autocompleteAction($term)
 {
     $searchProperty = $this->widgetConfiguration['searchProperty'];
     $query = $this->widgetConfiguration['objects']->getQuery();
     $constraint = $query->getConstraint();
     if ($constraint !== NULL) {
         $query->matching($query->logicalAnd($constraint, $query->like($searchProperty, '%' . $term . '%', FALSE)));
     } else {
         $query->matching($query->like($searchProperty, '%' . $term . '%', FALSE));
     }
     $results = $query->execute();
     $output = array();
     foreach ($results as $singleResult) {
         $val = \TYPO3\Fluid\Reflection\ObjectAccess::getProperty($singleResult, $searchProperty);
         $output[] = array('id' => $val, 'label' => $val, 'value' => $val);
     }
     return json_encode($output);
 }