GraphAware\Neo4j\OGM\Persister\RelationshipPersister::getRelationshipQuery PHP Метод

getRelationshipQuery() публичный Метод

public getRelationshipQuery ( $entityIdA, RelationshipMetadata $relationship, $entityIdB )
$relationship GraphAware\Neo4j\OGM\Metadata\RelationshipMetadata
    public function getRelationshipQuery($entityIdA, RelationshipMetadata $relationship, $entityIdB)
    {
        if ('' === trim($relationship->getType())) {
            throw new \RuntimeException(sprintf('Cannot create empty relationship type', $relationship->getPropertyName()));
        }
        $relString = '';
        switch ($relationship->getDirection()) {
            case 'OUTGOING':
                $relString = '-[r:%s]->';
                break;
            case 'INCOMING':
                $relString = '<-[r:%s]-';
                break;
            case 'BOTH':
                $relString = '-[r:%s]-';
                break;
            default:
                throw new \InvalidArgumentException(sprintf('Direction "%s" is not valid', $relationship->getDirection()));
        }
        $relStringPart = sprintf($relString, $relationship->getType());
        $query = 'MATCH (a), (b) WHERE id(a) = {ida} AND id(b) = {idb}
        MERGE (a)' . $relStringPart . '(b)
        RETURN id(r)';
        return Statement::create($query, ['ida' => $entityIdA, 'idb' => $entityIdB]);
    }