Guest User

Untitled

a guest
Dec 5th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1.  
  2. namespace Acme\Demo\Controller;
  3.  
  4. use TYPO3\Flow\Annotations as Flow;
  5.  
  6. /**
  7.  * Ajax controller for the Acme.Demo package
  8.  *
  9.  * @Flow\Scope("singleton")
  10.  */
  11. class AjaxController extends \TYPO3\Flow\Mvc\Controller\ActionController {
  12.  
  13.     /**
  14.      * @var array
  15.      * @see http://git.typo3.org/FLOW3/Packages/TYPO3.FLOW3.git?a=commit;h=03b6d85916e46ed8b2e99bc549d7248957dca935
  16.      */
  17.     protected $supportedMediaTypes = array('text/html', 'application/json');
  18.  
  19.     /**
  20.      * @var array
  21.      */
  22.     protected $viewFormatToObjectNameMap = array('json' => 'TYPO3\Flow\Mvc\View\JsonView');
  23.  
  24.     /**
  25.      * @Flow\Inject
  26.      * @var Acme\Demo\Domain\Repository\ScoutobjectRepository
  27.      */
  28.     protected $scoutobjectRepository;
  29.  
  30.     /**
  31.      * autocomplete user input
  32.      *
  33.      * @return void
  34.      */
  35.     public function autocompleteAction() {
  36.         $term = $this->request->getArgument('term');
  37.         $objects = $this->scoutobjectRepository->findCityForAutocompletion($term);
  38.         $objects2 = $this->scoutobjectRepository->findAll();      
  39.     }
  40. }
  41.  
  42.  
  43. *Repository*
  44.  
  45. namespace Acme\Demo\Domain\Repository;
  46.  
  47. /**
  48.  * A repository for ScoutObjects
  49.  *
  50.  * @Flow\Scope("singleton")
  51.  */
  52. class ScoutobjectRepository extends \TYPO3\Flow\Persistence\Repository {
  53.  
  54.     // add customized methods here
  55.     public function findCityForAutocompletion($term) {
  56.         $query = $this->createQuery();
  57.         $query->matching($query->like('gemeinde', $term.'%', FALSE));
  58.         $results = $query->execute();
  59.  
  60.         $query2 = $this->createQuery();
  61.         $query2->matching($query2->equals('gemeinde', 'Essen'));
  62.         $results2 = $query2->execute();
  63.  
  64.         return $results;
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment