Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function marshall($object)
 {
     if ($object instanceof NormDateTime) {
         return new MongoDate($object->getTimestamp());
     } elseif ($object instanceof NormArray) {
         return $object->toArray();
     } elseif ($object instanceof Object) {
         return $object->toObject();
     } else {
         return parent::marshall($object);
     }
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function marshall($object)
 {
     if ($object instanceof \Norm\Type\DateTime) {
         return $object->format('Y-m-d H:i:s');
     } elseif (is_array($object)) {
         $result = array();
         foreach ($object as $key => $value) {
             if ($key[0] === '$') {
                 if ($key === '$id' || $key === '$type') {
                     continue;
                 } else {
                     $result[substr($key, 1)] = $this->marshall($value);
                 }
             } else {
                 $result[$key] = $this->marshall($value);
             }
         }
         return $result;
     } else {
         return parent::marshall($object);
     }
 }