Пример #1
0
 /**
  * {% inheritdoc %}
  */
 public function hydrate($value, $propertyOptions)
 {
     $documentCollection = new DocumentCollection();
     foreach ($value as $doc) {
         $reference = $this->configurator->getClassForDocumentName($propertyOptions['reference']);
         $documentCollection->add($this->normalizer->denormalize($doc, $reference));
     }
     return $documentCollection;
 }
Пример #2
0
 /**
  * __call
  */
 public function __call($name, $args)
 {
     $data = call_user_func_array(array($this->collection, $name), $args);
     if ($data instanceof \MongoCursor) {
         $documentCollection = new DocumentCollection();
         foreach ($data as $array) {
             $document = $this->hydrateDocument($array);
             $documentCollection->add($document);
         }
         $this->joins(array());
         return $documentCollection;
     } elseif (is_array($data)) {
         if (array_key_exists('_id', $data)) {
             return $this->hydrateDocument($data);
         }
     }
     return $data;
 }