Identity() public method

If the entity is null returns a new blank identity otherwise returns the identity of the supplied entity.
public Identity ( object | null $Entity = null ) : Identity
$Entity object | null
return Identity The entity's identity
Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public final function MapPrimaryKeysToIdentities(array $PrimaryKeys)
 {
     $Identities = array_map(function () {
         return $this->EntityMap->Identity();
     }, $PrimaryKeys);
     foreach ($this->IdentityPropertyPrimaryKeyMappings as $Mapping) {
         $Mapping->Revive($PrimaryKeys, $Identities);
     }
     return $Identities;
 }
Ejemplo n.º 2
0
 /**
  * Loads an entity from given identity values or null if entity does not exist.
  * 
  * @param mixed ... The identity value(s)  
  * @return object|null The returned entity or null
  * @throws \Storm\Core\StormException
  */
 public function LoadById($_)
 {
     $IdentityValues = func_get_args();
     if (count($IdentityValues) !== count($this->IdentityProperties)) {
         throw new \Storm\Core\StormException('The supplied amount of parameters does not match the number of ' . 'identity properties for %s, expecting %d: %d were supplied', $this->EntityType, count($this->IdentityProperties), count($IdentityValues));
     }
     $Identity = $this->EntityMap->Identity();
     $Count = 0;
     foreach ($this->IdentityProperties as $IdentityProperty) {
         $Identity[$IdentityProperty] = $IdentityValues[$Count];
         $Count++;
     }
     return $this->LoadByIdentity($Identity);
 }
Ejemplo n.º 3
0
 public final function CacheEntity($Entity, Object\Identity $Identity = null)
 {
     $Identity = $Identity ?: $this->EntityMap->Identity($Entity);
     $IdentityHash = $Identity->Hash();
     $this->Cache->Save($IdentityHash, $Entity);
 }