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

deleteRefs() private method

Remove all references to this entity
private deleteRefs ( string $table_name, string $local_id )
$table_name string
$local_id string
    private function deleteRefs($table_name, $local_id)
    {
        $ref_key = $this->getKeyScheme()->getEntityRefKey($table_name, $local_id);
        $refs = $this->getDriver()->getRefs($ref_key);
        foreach ($refs as $ref) {
            $relationship = $this->getMapper()->getEntityMetadata($ref->getSourceClass())->getRelationshipByName($ref->getRelationshipName());
            $relationship_key = $this->getRelationshipKey($relationship, $ref->getEntityId());
            switch ($relationship->getRelationshipType()) {
                default:
                    throw new UnexpectedValueException("Unknown relationship type: " . $relationship->getRelationshipType()->value());
                case RelationshipType::MANYTOMANY():
                case RelationshipType::ONETOMANY():
                    $this->getDriver()->removeMultiValueIndex($relationship_key, $local_id);
                    break;
                case RelationshipType::MANYTOONE():
                case RelationshipType::ONETOONE():
                    $this->getDriver()->clearSingleValueIndex($relationship_key);
                    break;
            }
            foreach ($relationship->getSortableBy() as $sortable) {
                $sort_key = $this->getSortIndexKey($relationship, $sortable->getName(), $ref->getEntityId());
                $this->getDriver()->removeSortedIndex($sort_key, $local_id);
            }
        }
        $this->getDriver()->clearRefs($ref_key);
    }