Bravo3\Orm\Services\RelationshipManager::setMultiValueRelationship PHP Method

setMultiValueRelationship() private method

When setting forward indices the set is always cleared and re-added. This will fully synchronise the list and there is no need to calculate a delta, however it may be slow on large sets. Inverse relationships should always be updated via a delta operation.
private setMultiValueRelationship ( string $key, object[] | null $foreign_entities )
$key string
$foreign_entities object[] | null
    private function setMultiValueRelationship($key, $foreign_entities)
    {
        $this->getDriver()->clearMultiValueIndex($key);
        if ($foreign_entities) {
            $values = [];
            foreach ($foreign_entities as $entity) {
                $rel_metadata = $this->getMapper()->getEntityMetadata($entity);
                $rel_reader = new Reader($rel_metadata, $entity);
                $values[] = $rel_reader->getId();
            }
            $this->getDriver()->addMultiValueIndex($key, $values);
        }
    }