Persist() public method

Persist an entities data and relationships to the unit of work.
public Persist ( object $Entity ) : void
$Entity object The entity to persist
return void
示例#1
0
 public function testEntityIsPersisted()
 {
     $Entity = $this->Entity(null);
     $this->UnitOfWork->Persist($Entity);
     $this->assertCount(1, $this->UnitOfWork->GetPersistenceData());
     $this->assertArrayHasKey(self::EntityType, $this->UnitOfWork->GetPersistenceDataGroups());
     $this->assertCount(1, $this->UnitOfWork->GetPersistenceDataGroups()[self::EntityType]);
 }
示例#2
0
 public function GetPersistedRelationship(Object\Domain $Domain, Object\UnitOfWork $UnitOfWork, $ParentEntity, $RelatedEntity)
 {
     if ($this->CascadePersist && $this->IsEntityAltered($RelatedEntity)) {
         $UnitOfWork->Persist($RelatedEntity);
     }
     return $Domain->PersistedRelationship($ParentEntity, $RelatedEntity);
 }
示例#3
0
 /**
  * Constructs a unit of work instance containing the supplied operations to commit.
  * 
  * @param object[] $EntitiesToPersist
  * @param IProcedure[] $ProceduresToExecute
  * @param object[] $EntitiesToDiscard
  * @param ICriterion[] $CriterionToDiscard
  * @return UnitOfWork The constructed unit of work
  */
 public final function BuildUnitOfWork(array $EntitiesToPersist = [], array $ProceduresToExecute = [], array $EntitiesToDiscard = [], array $CriterionToDiscard = [])
 {
     $UnitOfWork = new UnitOfWork($this);
     foreach ($EntitiesToPersist as $Entity) {
         $UnitOfWork->Persist($Entity);
     }
     foreach ($ProceduresToExecute as $Procedure) {
         $UnitOfWork->Execute($Procedure);
     }
     foreach ($EntitiesToDiscard as $Entity) {
         $UnitOfWork->Discard($Entity);
     }
     foreach ($CriterionToDiscard as $Criterion) {
         $UnitOfWork->DiscardWhere($Criterion);
     }
     return $UnitOfWork;
 }