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

getJoinAlias() public static method

Gets the alias from a Join expression.
public static getJoinAlias ( Doctrine\ORM\Query\Expr\Join $join ) : string
$join Doctrine\ORM\Query\Expr\Join
return string
    public static function getJoinAlias(Join $join) : string
    {
        static $aliasProperty = null;
        static $initialized = false;
        if (!$initialized && !method_exists(Join::class, 'getAlias')) {
            $aliasProperty = new \ReflectionProperty(Join::class, '_alias');
            $aliasProperty->setAccessible(true);
            $initialized = true;
        }
        return null === $aliasProperty ? $join->getAlias() : $aliasProperty->getValue($join);
    }

Usage Example

 public function testGetJoinAliasWithReflection()
 {
     $methodExist = $this->getFunctionMock('ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Util', 'method_exists');
     $methodExist->expects($this->any())->with(Join::class, 'getAlias')->willReturn('false');
     $join = new Join('INNER_JOIN', 'relatedDummy', 'a_1', null, 'a_1.name = r.name');
     $this->assertEquals('a_1', QueryJoinParser::getJoinAlias($join));
 }
All Usage Examples Of ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryJoinParser::getJoinAlias