getRawProperty() public méthode

Returns property raw contents.
public getRawProperty ( string $name ) : mixed
$name string
Résultat mixed
Exemple #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->getRawProperty($name);
         if (!is_object($rawValue) && $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;
 }
 /**
  * Returns entity relationships as array, 0 => prePersist, 1 => postPersist
  * @param  IEntity  $entity
  * @return array
  */
 public static function getLoadedRelationships(IEntity $entity)
 {
     $isPersisted = $entity->isPersisted();
     $return = [[], []];
     foreach ($entity->getMetadata()->getProperties() as $propertyMeta) {
         if ($propertyMeta->relationship === NULL) {
             continue;
         }
         $name = $propertyMeta->name;
         $rawValue = $entity->getRawProperty($name);
         if (!is_object($rawValue) && ($propertyMeta->isNullable || $isPersisted)) {
             continue;
         }
         $property = $entity->getProperty($name);
         if ($property instanceof IRelationshipContainer) {
             if (!$property->isLoaded() && $isPersisted) {
                 continue;
             }
             $value = $entity->getValue($name);
             if ($value) {
                 if ($propertyMeta->relationship->type === PropertyRelationshipMetadata::ONE_HAS_ONE_DIRECTED && !$propertyMeta->relationship->isMain) {
                     $return[1][$name] = $value;
                 } else {
                     $return[0][$name] = $value;
                 }
             }
         } elseif ($property instanceof IRelationshipCollection) {
             if (!$property->isLoaded() && $isPersisted) {
                 continue;
             }
             $value = $entity->getValue($name);
             if ($value) {
                 $return[1][$name] = $value;
             }
         }
     }
     return $return;
 }
Exemple #3
0
 protected static function addRelationshipToQueue(IEntity $entity, PropertyMetadata $propertyMeta, IModel $model)
 {
     $isPersisted = $entity->isPersisted();
     $rawValue = $entity->getRawProperty($propertyMeta->name);
     if ($rawValue === null && ($propertyMeta->isNullable || $isPersisted)) {
         return;
     } elseif (!$entity->getProperty($propertyMeta->name)->isLoaded() && $isPersisted) {
         return;
     }
     $value = $entity->getValue($propertyMeta->name);
     $rel = $propertyMeta->relationship;
     if ($value instanceof IEntity && !$value->isPersisted() && ($rel->type !== Relationship::ONE_HAS_ONE || $rel->isMain)) {
         self::visitEntity($value, $model);
     } elseif ($value !== null) {
         self::$inputQueue[] = $value;
     }
 }