public function transform(IEntity $entity, $row)
 {
     foreach ($this->map->getAttributes() as $attribute) {
         /* @var $attribute MetaAttribute */
         if ($attribute->getType()->isState()) {
             $this->handleState($attribute, $entity, $row);
         } else {
             if ($attribute->getType()->isJsonSerializable()) {
                 $this->handleJsonSerializable($attribute, $entity, $row);
             } else {
                 $value = $this->rowValueFor($entity, $row, $attribute->getAttribute());
                 if ($value === null) {
                     continue;
                 }
                 if ($attribute->getType()->isJson()) {
                     $value = $this->handleJson($value);
                 } else {
                     if ($attribute->getType()->isInteger()) {
                         $value = $this->handleInteger($value);
                     } else {
                         if ($attribute->getType()->isFloat()) {
                             $value = $this->handleFloat($value);
                         } else {
                             if ($attribute->getType()->isBooleanYesNo()) {
                                 $value = $this->handleBooleanYesNo($value);
                             } else {
                                 if ($attribute->getType()->isBooleanInteger()) {
                                     $value = $this->handleBooleanInteger($value);
                                 } else {
                                     if ($attribute->getType()->isDatetime()) {
                                         $value = $this->handleDateTime($value);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($attribute->getType()->isDatetime()) {
                     $attribute->setEntityAttributeIfNotNull($entity, $value);
                 } else {
                     $attribute->setEntityAttribute($entity, $value);
                 }
             }
         }
     }
     return $entity;
 }
 public function transform()
 {
     $select = [];
     foreach ($this->map->getAttributes() as $attribute) {
         /* @var $attribute MetaAttribute */
         $attributeKey = $attribute->getAttribute();
         if ($this->prefix) {
             $attributeKey = ucfirst($attribute->getAttribute());
             $select[] = "{$this->prefix}.{$attribute->getColumn()} AS {$this->prefix}{$attributeKey}";
         } else {
             $select[] = "{$attribute->getColumn()} AS {$attributeKey}";
         }
     }
     if (count($select)) {
         return implode(', ', $select);
     }
     return null;
 }
 public function transform(IEntity $entity)
 {
     $row = [];
     foreach ($this->map->getAttributes() as $attribute) {
         /* @var $attribute MetaAttribute */
         if ($attribute->getSurrogate()) {
             continue;
         }
         $value = $attribute->getEntityAttribute($entity);
         if ($attribute->getType()->isState()) {
             $value = $this->handleState($value);
         } else {
             if ($attribute->getType()->isJsonSerializable()) {
                 $value = $this->handleJsonSerializable($value);
             } else {
                 if ($attribute->getType()->isJson()) {
                     $value = $this->handleJson($value);
                 } else {
                     if ($attribute->getType()->isBooleanYesNo()) {
                         $value = $this->handleBooleanYesNo($value);
                     } else {
                         if ($attribute->getType()->isBooleanInteger()) {
                             $value = $this->handleBooleanInteger($value);
                         } else {
                             if ($attribute->getType()->isDatetime()) {
                                 $value = $this->handleDateTime($value);
                             }
                         }
                     }
                 }
             }
         }
         $row[$attribute->getColumn()] = $value;
     }
     return $row;
 }
Esempio n. 4
0
 /**
  *
  * @return MetaAttribute
  */
 public function getSurrogateAttribute()
 {
     return $this->map->getSurrogate();
 }