PHP Class Bravo3\Orm\Services\RelationshipManager

Inheritance: extends AbstractManagerUtility
Show file Open project: bravo3/orm

Public Methods

Method Description
deleteRelationships ( object $entity, Entity $metadata = null, Reader $reader = null, string $local_id = null ) Delete relationship & sort indices
invertRelationship ( Relationship $relationship ) : Relationship Returns the inverse equivalent of a given relationship
persistRelationships ( object $entity, Entity $metadata = null, Reader $reader = null, string $local_id = null ) Persist entity relationships

Private Methods

Method Description
breakFormerRelationship ( Relationship $relationship, string $source_id ) When adding an entity on a one-to-many relationship, the foreign entity might have had a pre-existing entity assigned in the inverted 'to-one' index. If it had a value, we now need to break that existing relationship as we have inadvertently removed it by assigning it to a new local entity.
deleteInvertedRelationship ( Relationship $inverse_relationship, string $foreign_id, string $local_id ) Remove the local ID from an inverse relationships and sort indices
deleteRefs ( string $table_name, string $local_id ) Remove all references to this entity
deleteRelationshipRefs ( Relationship $relationship, object | object[] $value, string $local_id ) Delete all references created by this relationship
deleteRelationshipsTraversal ( Entity $metadata, object $entity, Reader $reader, string $local_id ) Traverse the given list of relationships and delete them
getRelationshipDeltas ( string $key, Relationship $relationship, object | object[] $new_value ) : array Get an array containing an array of foreign entities to remove the local entity from, and an array of foreign entities to add the local entity to and an array of entities which remain the same in the relationship
getRelationshipDeltasMulti ( string $key, object | object[] $new_value ) : array Get the deltas for a to-many relationship
getRelationshipDeltasSingle ( string $key, object | object[] $new_value ) : array Get the deltas for a to-one relationship
persistForwardRelationship ( Relationship $relationship, string $key, object | object[] $value ) Persist the forward side of a relationship
persistForwardSortIndices ( Relationship $relationship, string $local_id, object | object[] $value ) Persist forward sorted indices
persistInversedRelationship ( Relationship $relationship, string $key, object | object[] $value, string $local_id, Reader $reader ) Persist the inverse side of a relationship
persistRefs ( Relationship $relationship, string $key, object | object[] $value, string $local_id ) Persist refs in place of inverted indices
persistRelationshipsTraversal ( Entity $metadata, object $entity, Reader $reader, string $local_id ) Traverse an array of relationships and persist them
setMultiValueRelationship ( string $key, object[] | null $foreign_entities ) Set a forward multi-value relationship index
setSingleValueRelationship ( string $key, object $foreign_entity ) Set a single-key relationship index
updateMaintainedRelationshipSortIndices ( Relationship $inverse_relationship, string[] $maintain, Reader $reader, string $local_id ) Re-test and update inverted sort-by columns for maintained relationship entities
updateRefs ( string $table_name, string $local_id, Reader $reader ) Update references to this entity (such as conditional sort indices)

Method Details

deleteRelationships() public method

Delete relationship & sort indices
public deleteRelationships ( object $entity, Entity $metadata = null, Reader $reader = null, string $local_id = null )
$entity object Local entity object
$metadata Bravo3\Orm\Mappers\Metadata\Entity Optionally provide entity metadata to prevent recalculation
$reader Bravo3\Orm\Services\Io\Reader Optionally provide the entity reader
$local_id string Optionally provide the local entity ID to prevent recalculation

invertRelationship() public method

Returns the inverse equivalent of a given relationship
public invertRelationship ( Relationship $relationship ) : Relationship
$relationship Bravo3\Orm\Mappers\Metadata\Relationship
return Bravo3\Orm\Mappers\Metadata\Relationship

persistRelationships() public method

Persist entity relationships
public persistRelationships ( object $entity, Entity $metadata = null, Reader $reader = null, string $local_id = null )
$entity object Local entity object
$metadata Bravo3\Orm\Mappers\Metadata\Entity Optionally provide entity metadata to prevent recalculation
$reader Bravo3\Orm\Services\Io\Reader Optionally provide the entity reader
$local_id string Optionally provide the local entity ID to prevent recalculation