Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * Test if default file format works
  *
  * @test
  * @dataProvider orderDataProvider
  * @return void
  */
 public function testForValidOrdering($expectedFields, $expected)
 {
     $validation = Validation::isValidOrdering($expectedFields, self::ALLOWED_FIELDS);
     $this->assertEquals($validation, $expected);
 }