Set a given relationship on this relation.

@param \\Orientdb\Relationship $relation
779129
public function setRelation(Relationship $relation, $debug = false)
    {
        // Set the relation object.
        $this->relation = $relation;

        // Replace the attributes with those brought from the given relation.
        $this->attributes = $relation->getProperties();
        //$this->setAttribute($this->primaryKey, $relation->getId());

        // Set the start and end nodes.
        $this->start = $relation->getStartNode();
        $this->end   = $relation->getEndNode();

        // Instantiate and fill out the related model.
        $relatedNode = ($this->isDirectionOut()) ? $this->end : $this->start;
        $attributes = array_merge(['id' => $relatedNode->getId()], $relatedNode->getProperties());

        // This is an existing relationship.
        $exists = true;
        $this->related = $this->related->newFromBuilder($attributes, $exists);
        $this->related->setConnection($this->related->getConnection());
    }
592795
public static function normalizeToManyRelation($relation, $relationship)
    {
        if (is_array($relation)) {
            $relation = new ArrayCollection($relation);
        } elseif (is_null($relation)) {
            throw new \Exception(sprintf(
                self::ERROR_TO_MANY_RELATION_NULL, $relationship
            ));
        } elseif (!$relation instanceof CollectionInterface) {
            $type = is_object($relation)
                ? get_class($relation)
                : gettype($relation);

            throw new \Exception(sprintf(
                self::ERROR_NOT_ENTITY_COLLECTION, $relationship, $type
            ));
        }

        return $relation;
    }
876074
protected function addManyRelation(string $relation)
    {
        if (!in_array($relation, $this->manyRelations)) {
            $this->manyRelations[] = $relation;
        }
    }
380918
public function setRelationValue($object, $relationName, $value)
    {
        $this->assertObjectInstance($object);

        $relation = $this->getRelation($relationName);

        $relationData = $relation->getForeignKeyValue($value);
        $state        = $this->getState($object);
        $state->setRelationForeignKeys($relationName, $relationData);
        $state->setRelationLoaded($relationName);

        return $relation->set($object, $value);
    }
390533
private function isRelationForeignKeyNullable(Relation $relation)
    {
        $reflectionObj = new \ReflectionObject($relation);
        if (!$reflectionObj->hasProperty('foreignKey')) {
            return false;
        }
        $fkProp = $reflectionObj->getProperty('foreignKey');
        $fkProp->setAccessible(true);

        return isset($this->nullableColumns[$fkProp->getValue($relation)]);
    }
446890
protected function setPlatformRelationship($relationship)
    {
        if (null !== $relationship) {
            $this->writeAttribute(
                $relationship,
                'platform',
                'relationship',
                $this->validator,
                'validatePlatformRelationship',
                $this->exception,
                'Provided relationship is not a valid value.'
            );
        }

        return $this;
    }
901785
public function addCloneableRelation($relation) {
		$relations = $this->getCloneableRelations();
		if (in_array($relation, $relations)) return;
		$relations[] = $relation;
		$this->cloneable_relations = $relations;
	}
401560
public function eagerLoad($relationship)
	{
		if(is_array($relationship))
		{
			foreach($relationship as $key)
			{
				$this->eagerLoad[] = $key;
			}
		}
		else
		{
			$this->eagerLoad[] = $relationship;
		}
	}
545039
public function setProxies(array $relations = null)
    {
        $attributes = $this->getEntityAttributes();
        $proxies = [];

        $relations = $this->getRelationsToProxy();

        // Before calling the relationship methods, we'll set the relationship
        // method to null, to avoid hydration error on class properties
        foreach ($relations as $relation) {
            $this->setEntityAttribute($relation, null);
        }

        foreach ($relations as $relation) {
            // First, we check that the relation has not been already
            // set, in which case, we'll just pass.
            if (array_key_exists($relation, $attributes) && !is_null($attributes[$relation])) {
                continue;
            }

            // If the key is handled locally and we know it not to be set,
            // we'll set the relationship to null value
            if (!$this->relationNeedsProxy($relation, $attributes)) {
                $proxies[$relation] = $this->entityMap->getEmptyValueForRelationship($relation);
            } else {
                $targetClass = $this->getClassToProxy($relation, $attributes);
                $proxies[$relation] = $this->proxyFactory->make($this->getObject(), $relation, $targetClass);
            }
        }

        foreach ($proxies as $key => $value) {
            $this->setEntityAttribute($key, $value);
        }
    }
879628
public void addRelation(String property, Relation relation)
    {
        relationsMap.put(property, relation);
        addRelationName(relation);
    }
189102
protected function isActualRelationships(string $relation): bool
    {
        return array_key_exists($relation, $this->relationships)
            && count($this->relationships[$relation]) > 0;
    }
560661
protected function addPolymorphicRelation(string $relation)
    {
        if (!in_array($relation, $this->polymorphicRelations)) {
            $this->polymorphicRelations[] = $relation;
        }
    }
1259171
protected function handleLinks(array $data, Relationship $relationship)
    {
        if (! isset($data['links'])) {
            return;
        }

        foreach ($data['links'] as $linkName => $linkData)
        {
            $link = $this->createLink($linkName, $linkData);

            $relationship->addLink($link);
        }
    }
238710
public function appendRelation($relation, $value)
    {
        if (!array_key_exists($relation, $this->getRelations())) {
            $this->setRelation($relation, new Collection([$value]));
        } else {
            $this->getRelation($relation)->add($value);
        }

        return $this;
    }
829309
protected function _setRelationForeignKeys($relationName)
    {
        /** @var BaseActiveRecord $owner */
        $owner = $this->owner;
        /** @var ActiveQuery $relation */
        $relation = $owner->getRelation($relationName);
        if ($relation->multiple === false && !empty($owner->{$relationName})) {
            Yii::debug("Setting foreign keys for {$relationName}", __METHOD__);
            foreach ($relation->link as $relatedAttribute => $modelAttribute) {
                if ($owner->{$modelAttribute} !== $owner->{$relationName}->{$relatedAttribute}) {
                    if ($owner->{$relationName}->isNewRecord) {
                        $owner->{$relationName}->save();
                    }
                    $owner->{$modelAttribute} = $owner->{$relationName}->{$relatedAttribute};
                }
            }
        }
    }
698049
public function lazyLoad($relationship)
	{
		if(is_array($relationship))
		{
			foreach($relationship as $key)
			{
				$this->lazyLoad[] = $key;
			}
		}
		else
		{
			$this->lazyLoad[] = $relationship;
		}
	}
261995
public static function validateToOneRelation($relation, $relationship)
    {
        if (
            !is_null($relation)
            && !$relation instanceof ResourceEntityInterface
        ) {
            $type = is_object($relation)
                ? get_class($relation) : gettype($relation);
            throw new \Exception(sprintf(
                self::ERROR_NOT_RESOURCE_ENTITY, $relationship, $type
            ));
        }
    }