Storm\Core\Object\UnitOfWork::Persist PHP Method

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
    public function Persist($Entity)
    {
        $Hash = spl_object_hash($Entity);
        if (isset($this->PersistenceData[$Hash])) {
            return;
        }
        $PersistenceData = $this->Domain->Persist($this, $Entity);
        $this->PersistenceData[$Hash] = $PersistenceData;
        $this->PersistenceDataEntityMap[$PersistenceData] = $Entity;
        $EntityType = $PersistenceData->GetEntityType();
        if (!isset($this->PersistenceDataGroups[$EntityType])) {
            $this->PersistenceDataGroups[$EntityType] = [];
        }
        $this->PersistenceDataGroups[$EntityType][] = $PersistenceData;
    }

Usage Example

Esempio n. 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]);
 }
All Usage Examples Of Storm\Core\Object\UnitOfWork::Persist