SHOW:
|
|
- or go back to the newest paste.
| 1 | //CONTROLLER | |
| 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* |
| 43 | + | //REPOSITORY |
| 44 | namespace Acme\Demo\Domain\Repository; | |
| 45 | ||
| 46 | /** | |
| 47 | * A repository for ScoutObjects | |
| 48 | * | |
| 49 | * @Flow\Scope("singleton")
| |
| 50 | */ | |
| 51 | class ScoutobjectRepository extends \TYPO3\Flow\Persistence\Repository {
| |
| 52 | ||
| 53 | // add customized methods here | |
| 54 | public function findCityForAutocompletion($term) {
| |
| 55 | $query = $this->createQuery(); | |
| 56 | $query->matching($query->like('gemeinde', $term.'%', FALSE));
| |
| 57 | $results = $query->execute(); | |
| 58 | ||
| 59 | $query2 = $this->createQuery(); | |
| 60 | $query2->matching($query2->equals('gemeinde', 'Essen'));
| |
| 61 | $results2 = $query2->execute(); | |
| 62 | ||
| 63 | return $results; | |
| 64 | } | |
| 65 | } |