Exemplo n.º 1
0
 /**
  * 把存储服务内获取的数据,打包成Data实例
  *
  * @param array $record
  * @param Data [$data]
  * @return Data
  */
 public function pack(array $record, Data $data = null)
 {
     $types = Types::getInstance();
     $values = array();
     foreach ($record as $key => $value) {
         $attribute = $this->getAttribute($key);
         if ($attribute && !$attribute['deprecated']) {
             $values[$key] = $types->get($attribute['type'])->restore($value, $attribute);
         }
     }
     if ($data) {
         $data->__pack($values, false);
     } else {
         $class = $this->class;
         $data = new $class(null, array('fresh' => false));
         $data->__pack($values, true);
     }
     return $data;
 }