/** * Main action terms will be sorted * by the currentCharacter * * @param string $character * * @throws Exception * * @return void */ public function indexAction($character = '') { if (TRUE === empty($character)) { $this->query->setLimit(1)->setOrderings(array($this->field => QueryInterface::ORDER_ASCENDING)); $firstObject = $this->query->execute()->toArray(); $this->query = $this->objects->getQuery(); if (TRUE === empty($firstObject)) { $this->view->assign('noObjects', TRUE); } else { $getter = 'get' . GeneralUtility::underscoredToUpperCamelCase($this->field); if (TRUE === method_exists($firstObject[0], $getter)) { $this->currentCharacter = strtoupper(substr($firstObject[0]->{$getter}(), 0, 1)); } else { throw new Exception('Getter for "' . $this->field . '" in "' . get_class($firstObject[0]) . '" does not exist', 1433257601); } } } else { $this->currentCharacter = $character; } $this->currentCharacter = str_replace(array('AE', 'OE', 'UE'), array('Ä', 'Ö', 'Ü'), $this->currentCharacter); $objects = $this->getMatchings()->execute()->toArray(); $this->view->assign('configuration', $this->configuration); $this->view->assign('pagination', $this->buildPagination()); $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $objects)); }
/** * Check the constraint and execute the query * * @param QueryInterface $query * @param array $constraints * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ public function matchAndExecute(QueryInterface $query, array $constraints = []) { if ($constraints) { $query->matching($query->logicalAnd($constraints)); } return $query->execute(); }
/** * Returns the objects of this repository matching the given demand * * @param \SKYFILLERS\SfSimpleFaq\Domain\Model\Dto\FaqDemand $demand A demand * * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ public function findByDemand(FaqDemand $demand) { $this->query = $this->createQuery(); $this->generateCategories($demand); $this->generateSearchConstraints($demand); $this->buildQuery(); return $this->query->execute(); }
/** * @param QueryInterface $query * @return array */ protected function addOptionsFromResults(QueryInterface $query) { $items = array(); $results = $query->execute(); $type = $query->getType(); $table = strtolower(str_replace('\\', '_', $type)); $propertyName = $this->getLabelPropertyName($table, $type); foreach ($results as $result) { $uid = $result->getUid(); array_push($items, array(ObjectAccess::getProperty($result, $propertyName), $uid)); } return $items; }
/** * Returns the result of the query based on the given displaymode set in demand * * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query The query * @param \DERHANSEN\SfBanners\Domain\Model\BannerDemand $demand The demand * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ protected function getResult(QueryInterface $query, BannerDemand $demand) { $result = array(); // Do not respect syslanguage since we search for uids - @see forge #47192 $query->getQuerySettings()->setRespectSysLanguage(false); switch ($demand->getDisplayMode()) { case 'all': $result = $query->execute(); break; case 'allRandom': $result = $this->objectManager->get('DERHANSEN\\SfBanners\\Persistence\\RandomQueryResult', $query); break; case 'random': $rows = $query->execute()->count(); $rowNumber = mt_rand(0, max(0, $rows - 1)); $result = $query->setOffset($rowNumber)->setLimit(1)->execute(); break; default: break; } return $result; }