Discard() public method

Discards the supplied entity
public Discard ( object $Entity ) : void
$Entity object The entity to discard
return void
Example #1
0
 public function testEntityWithoutIdentityIsDiscarded()
 {
     $Entity = $this->Entity(null);
     $this->UnitOfWork->Discard($Entity);
     $this->assertCount(0, $this->UnitOfWork->GetDiscardenceData());
     $this->assertCount(0, $this->UnitOfWork->GetDiscardenceDataGroups());
 }
Example #2
0
 public function GetDiscardedRelationship(Object\Domain $Domain, Object\UnitOfWork $UnitOfWork, $ParentEntity, $RelatedEntity)
 {
     if ($this->CascadeDiscard) {
         $UnitOfWork->Discard($RelatedEntity);
     }
     return $Domain->DiscardedRelationship($ParentEntity, $RelatedEntity);
 }
Example #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;
 }