Ejemplo n.º 1
0
 /**
  * Sets sortings on an extbase query by given query object. Returns manipulated extbase query.
  *
  * @param Tx_PtExtlist_Domain_QueryObject_Query $query Query object to get sortings from
  * @param \TYPO3\CMS\Extbase\Persistence\Generic\Query $extbaseQuery Query object to set sortings on
  * @return \TYPO3\CMS\Extbase\Persistence\Generic\Query Manipulated ExtBase query object
  */
 public static function setSortingOnExtBaseQueryByQueryObject(Tx_PtExtlist_Domain_QueryObject_Query $query, \TYPO3\CMS\Extbase\Persistence\Generic\Query $extbaseQuery)
 {
     $sortings = $query->getSortings();
     $extBaseSortings = array();
     foreach ($sortings as $field => $direction) {
         /* sorting is array('field' => 'Direction: 1 | -1') */
         $extBaseDirection = $direction == Tx_PtExtlist_Domain_QueryObject_Query::SORTINGSTATE_ASC ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING;
         $extBaseSortings[$field] = $extBaseDirection;
     }
     $extbaseQuery->setOrderings($extBaseSortings);
     return $extbaseQuery;
 }