Storm\Core\Mapping\DomainDatabaseMap::Load PHP Method

Load() final public method

Loads all entities that are specified from the given request instance.
final public Load ( Storm\Core\Object\IRequest $ObjectRequest ) : array | object | null
$ObjectRequest Storm\Core\Object\IRequest The request to load
return array | object | null Depending on the supplied request, either all the entities are returned as an array or the first is returned or null if none are found.
    public final function Load(Object\IRequest $ObjectRequest)
    {
        $EntityType = $ObjectRequest->GetEntityType();
        $this->VerifyEntityTypeIsMapped($EntityType);
        $RelationalRequest = $this->MapRequest($ObjectRequest);
        $ResultRows = $this->Database->Load($RelationalRequest);
        $RevivalDataArray = $this->MapRowsToRevivalData($EntityType, $ResultRows);
        $RevivedEntities = $this->Domain->ReviveEntities($EntityType, $RevivalDataArray);
        if ($ObjectRequest->IsSingleEntity()) {
            return count($RevivedEntities) > 0 ? reset($RevivedEntities) : null;
        } else {
            return $RevivedEntities;
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Loads an entity from an identity instance.
  * 
  * @param Object\Identity $Identity The identity of the entity
  * @return object|null
  */
 protected function LoadByIdentity(Object\Identity $Identity)
 {
     $CachedEntity = $this->IdentityMap->GetFromCache($Identity);
     if ($CachedEntity instanceof $this->EntityType) {
         return $CachedEntity;
     }
     $Entity = $this->DomainDatabaseMap->Load(new Base\Object\Request($this->EntityType, $this->EntityMap->GetProperties(), true, new Base\Object\Criteria\MatchesCriterion($Identity)));
     if ($Entity instanceof $this->EntityType) {
         $this->IdentityMap->CacheEntity($Entity, $Identity);
     }
     return $Entity;
 }