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

getJoinRelationship() public static method

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

Usage Example

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