ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryJoinParser::getOrderByParts PHP Method

getOrderByParts() public static method

Gets the parts from an OrderBy expression.
public static getOrderByParts ( Doctrine\ORM\Query\Expr\OrderBy $orderBy ) : array
$orderBy Doctrine\ORM\Query\Expr\OrderBy
return array
    public static function getOrderByParts(OrderBy $orderBy) : array
    {
        static $partsProperty = null;
        static $initialized = false;
        if (!$initialized && !method_exists(OrderBy::class, 'getParts')) {
            $partsProperty = new \ReflectionProperty(OrderBy::class, '_parts');
            $partsProperty->setAccessible(true);
            $initialized = true;
        }
        return null === $partsProperty ? $orderBy->getParts() : $partsProperty->getValue($orderBy);
    }

Usage Example

Esempio n. 1
0
 public function testGetOrderByPartsWithReflection()
 {
     $methodExist = $this->getFunctionMock('ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Util', 'method_exists');
     $methodExist->expects($this->any())->with(OrderBy::class, 'getParts')->willReturn('false');
     $orderBy = new OrderBy('name', 'desc');
     $this->assertEquals(['name desc'], QueryJoinParser::getOrderByParts($orderBy));
 }
All Usage Examples Of ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryJoinParser::getOrderByParts