Nextras\Orm\Entity\IEntity::getRawValue PHP Method

getRawValue() public method

Raw value is normalized value which is suitable unique identification and storing.
public getRawValue ( string $name ) : mixed
$name string
return mixed
    public function &getRawValue($name);

Usage Example

Beispiel #1
0
 /**
  * Returns entity relationships as array, 0 => pre, 1 => post, 2 => nulls
  * @param  IEntity  $entity
  * @return array
  */
 public static function getRelationships(IEntity $entity)
 {
     $return = [[], [], []];
     foreach ($entity->getMetadata()->getProperties() as $propertyMeta) {
         if ($propertyMeta->relationship === null) {
             continue;
         }
         $name = $propertyMeta->name;
         if (!$propertyMeta->relationship->cascade['remove']) {
             $return[2][$name] = $propertyMeta;
             continue;
         }
         $rawValue = $entity->getRawValue($name);
         if ($rawValue === null && $propertyMeta->isNullable) {
             continue;
         }
         $property = $entity->getProperty($name);
         if ($property instanceof IRelationshipContainer) {
             $value = $entity->getValue($name);
             if ($value) {
                 if ($propertyMeta->relationship->type === Relationship::ONE_HAS_ONE && !$propertyMeta->relationship->isMain) {
                     $return[0][$name] = $value;
                 } else {
                     $return[1][$name] = $value;
                 }
             }
         } elseif ($property instanceof IRelationshipCollection) {
             $return[0][$name] = $entity->getValue($name);
         }
     }
     return $return;
 }
All Usage Examples Of Nextras\Orm\Entity\IEntity::getRawValue