コード例 #1
0
 /**
  * Parses the order by clause and transforms it into AST
  * @param string $orderByClause
  * @return \Doctrine\ORM\Query\AST\OrderByClause
  */
 protected function parseOrderByClause($orderByClause)
 {
     if ($orderByClause === '') {
         return new \Doctrine\ORM\Query\AST\OrderByClause([]);
         // Empty order by ===> RETURN
     }
     // We use the doctrine DQL parser here.
     // Fortunately the function OrderByClause is public, thus we can call it directly.
     // Let's hope that it stays public and never breaks
     $dummyQuery = $this->_getQuery()->getEntityManager()->createQuery('order by ' . $orderByClause);
     $parser = new \Doctrine\ORM\Query\Parser($dummyQuery);
     $parser->getLexer()->moveNext();
     // Move to first token
     return $parser->OrderByClause();
 }