public function getOrderByIdentifier($orderBy)
    {
        $objectManager = $this->getObjectManager();
        $classMetadata = $objectManager->getClassMetadata($this->getEntityClass());

        if (strpos($orderBy, '::') === false) {

            if (!$classMetadata->hasField($orderBy)) {
                throw new \InvalidArgumentException(sprintf(
                    'Invalid order by column: Entity "%s" has no field "%s"',
                    $this->getEntityClass(),
                    $orderBy
                ));
            }

            $orderByIdentifier = $this->getEntityClassAlias()
                               . '.'
                               . $orderBy;
        } else {
            list($association, $assocProperty) = explode('::', $orderBy);

            if (!$classMetadata->hasAssociation($association)) {
                throw new \InvalidArgumentException(sprintf(
                    'Invalid order by column: Entity "%s" has no association "%s"',
                    $this->getEntityClass(),
                    $association
                ));
            }

            if (in_array($assocProperty, array('count'))) {
                //@FIXME
                $orderByIdentifier = $this->getEntityClassAlias()
                                   . '.id';

            } else {
                $assocTargetClass = $classMetadata->getAssociationTargetClass($association);

                if (!$objectManager->getClassMetadata($assocTargetClass)->hasField($assocProperty)) {
                    throw new \InvalidArgumentException(sprintf(
                        'Invalid order by column: Entity "%s" has no field "%s"',
                        $assocTargetClass,
                        $assocProperty
                    ));
                }

                $joinAlias         = self::JOIN_ALIAS_PREFIX . $association;
                $orderByIdentifier = $joinAlias . '.' . $assocProperty;
            }
        }

        return $orderByIdentifier;
    }
public function getOrderByIdentifier($orderBy)
    {
        $objectManager = $this->getObjectManager();
        $classMetadata = $objectManager->getClassMetadata($this->getEntityClass());

        if (strpos($orderBy, '::') === false) {

            if (!$classMetadata->hasField($orderBy)) {
                throw new \InvalidArgumentException(sprintf(
                    'Invalid order by column: Entity "%s" has no field "%s"',
                    $this->getEntityClass(),
                    $orderBy
                ));
            }

            $orderByIdentifier = $this->getEntityClassAlias()
                               . '.'
                               . $orderBy;
        } else {
            list($association, $assocProperty) = explode('::', $orderBy);

            if (!$classMetadata->hasAssociation($association)) {
                throw new \InvalidArgumentException(sprintf(
                    'Invalid order by column: Entity "%s" has no association "%s"',
                    $this->getEntityClass(),
                    $association
                ));
            }

            if (in_array($assocProperty, array('count'))) {
                //@FIXME
                $orderByIdentifier = $this->getEntityClassAlias()
                                   . '.id';

            } else {
                $assocTargetClass = $classMetadata->getAssociationTargetClass($association);

                if (!$objectManager->getClassMetadata($assocTargetClass)->hasField($assocProperty)) {
                    throw new \InvalidArgumentException(sprintf(
                        'Invalid order by column: Entity "%s" has no field "%s"',
                        $assocTargetClass,
                        $assocProperty
                    ));
                }

                $joinAlias         = self::JOIN_ALIAS_PREFIX . $association;
                $orderByIdentifier = $joinAlias . '.' . $assocProperty;
            }
        }

        return $orderByIdentifier;
    }
public function getOrderByIdentifier ( $ orderBy ) { $ objectManager = $ this -> getObjectManager ( ) ; $ classMetadata = $ objectManager -> getClassMetadata ( $ this -> getEntityClass ( ) ) ; if ( strpos ( $ orderBy , '::' ) === false ) { if ( ! $ classMetadata -> hasField ( $ orderBy ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid order by column: Entity "%s" has no field "%s"' , $ this -> getEntityClass ( ) , $ orderBy ) ) ; } $ orderByIdentifier = $ this -> getEntityClassAlias ( ) . '.' . $ orderBy ; } else { list ( $ association , $ assocProperty ) = explode ( '::' , $ orderBy ) ; if ( ! $ classMetadata -> hasAssociation ( $ association ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid order by column: Entity "%s" has no association "%s"' , $ this -> getEntityClass ( ) , $ association ) ) ; } if ( in_array ( $ assocProperty , array ( 'count' ) ) ) { //@FIXME $ orderByIdentifier = $ this -> getEntityClassAlias ( ) . '.id' ; } else { $ assocTargetClass = $ classMetadata -> getAssociationTargetClass ( $ association ) ; if ( ! $ objectManager -> getClassMetadata ( $ assocTargetClass ) -> hasField ( $ assocProperty ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid order by column: Entity "%s" has no field "%s"' , $ assocTargetClass , $ assocProperty ) ) ; } $ joinAlias = self :: JOIN_ALIAS_PREFIX . $ association ; $ orderByIdentifier = $ joinAlias . '.' . $ assocProperty ; } } return $ orderByIdentifier ; }
Returns the column identifier for the order by property

@param sting $orderBy
@throws \InvalidArgumentException
@return string
Returns the column identifier for the order by property