/** * Returns an array of orderings created from a given demand object. * * @param DemandInterface $demand * @return array<\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface> */ protected function createOrderingsFromDemand(DemandInterface $demand) { $orderings = []; if (Validation::isValidOrdering($demand->getOrder(), $demand->getOrderByAllowed())) { $orderList = GeneralUtility::trimExplode(',', $demand->getOrder(), true); if (!empty($orderList)) { // go through every order statement foreach ($orderList as $orderItem) { list($orderField, $ascDesc) = GeneralUtility::trimExplode(' ', $orderItem, true); // count == 1 means that no direction is given if ($ascDesc) { $orderings[$orderField] = strtolower($ascDesc) == 'desc' ? QueryInterface::ORDER_DESCENDING : QueryInterface::ORDER_ASCENDING; } else { $orderings[$orderField] = QueryInterface::ORDER_ASCENDING; } } } } return $orderings; }