original_string: public function hydrate($document, $data, array $hints = array())
      {
          $metadata = $this->dm->getClassMetadata(get_class($document));
          // Invoke preLoad lifecycle events and listeners
          if ( ! empty($metadata->lifecycleCallbacks[Events::preLoad])) {
              $args = array(&$data);
              $metadata->invokeLifecycleCallbacks(Events::preLoad, $document, $args);
          }
          if ($this->evm->hasListeners(Events::preLoad)) {
              $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($document, $this->dm, $data));
          }
  
          // alsoLoadMethods may transform the document before hydration
          if ( ! empty($metadata->alsoLoadMethods)) {
              foreach ($metadata->alsoLoadMethods as $method => $fieldNames) {
                  foreach ($fieldNames as $fieldName) {
                      // Invoke the method only once for the first field we find
                      if (array_key_exists($fieldName, $data)) {
                          $document->$method($data[$fieldName]);
                          continue 2;
                      }
                  }
              }
          }
  
          $data = $this->getHydratorFor($metadata->name)->hydrate($document, $data, $hints);
          if ($document instanceof Proxy) {
              $document->__isInitialized__ = true;
          }
  
          // Invoke the postLoad lifecycle callbacks and listeners
          if ( ! empty($metadata->lifecycleCallbacks[Events::postLoad])) {
              $metadata->invokeLifecycleCallbacks(Events::postLoad, $document);
          }
          if ($this->evm->hasListeners(Events::postLoad)) {
              $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($document, $this->dm));
          }
  
          return $data;
      }
code: public function hydrate($document, $data, array $hints = array())
      {
          $metadata = $this->dm->getClassMetadata(get_class($document));
          // Invoke preLoad lifecycle events and listeners
          if ( ! empty($metadata->lifecycleCallbacks[Events::preLoad])) {
              $args = array(&$data);
              $metadata->invokeLifecycleCallbacks(Events::preLoad, $document, $args);
          }
          if ($this->evm->hasListeners(Events::preLoad)) {
              $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($document, $this->dm, $data));
          }
  
          // alsoLoadMethods may transform the document before hydration
          if ( ! empty($metadata->alsoLoadMethods)) {
              foreach ($metadata->alsoLoadMethods as $method => $fieldNames) {
                  foreach ($fieldNames as $fieldName) {
                      // Invoke the method only once for the first field we find
                      if (array_key_exists($fieldName, $data)) {
                          $document->$method($data[$fieldName]);
                          continue 2;
                      }
                  }
              }
          }
  
          $data = $this->getHydratorFor($metadata->name)->hydrate($document, $data, $hints);
          if ($document instanceof Proxy) {
              $document->__isInitialized__ = true;
          }
  
          // Invoke the postLoad lifecycle callbacks and listeners
          if ( ! empty($metadata->lifecycleCallbacks[Events::postLoad])) {
              $metadata->invokeLifecycleCallbacks(Events::postLoad, $document);
          }
          if ($this->evm->hasListeners(Events::postLoad)) {
              $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($document, $this->dm));
          }
  
          return $data;
      }
code_tokens: public function hydrate ( $ document , $ data , array $ hints = array ( ) ) { $ metadata = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; // Invoke preLoad lifecycle events and listeners if ( ! empty ( $ metadata -> lifecycleCallbacks [ Events :: preLoad ] ) ) { $ args = array ( & $ data ) ; $ metadata -> invokeLifecycleCallbacks ( Events :: preLoad , $ document , $ args ) ; } if ( $ this -> evm -> hasListeners ( Events :: preLoad ) ) { $ this -> evm -> dispatchEvent ( Events :: preLoad , new PreLoadEventArgs ( $ document , $ this -> dm , $ data ) ) ; } // alsoLoadMethods may transform the document before hydration if ( ! empty ( $ metadata -> alsoLoadMethods ) ) { foreach ( $ metadata -> alsoLoadMethods as $ method => $ fieldNames ) { foreach ( $ fieldNames as $ fieldName ) { // Invoke the method only once for the first field we find if ( array_key_exists ( $ fieldName , $ data ) ) { $ document -> $ method ( $ data [ $ fieldName ] ) ; continue 2 ; } } } } $ data = $ this -> getHydratorFor ( $ metadata -> name ) -> hydrate ( $ document , $ data , $ hints ) ; if ( $ document instanceof Proxy ) { $ document -> __isInitialized__ = true ; } // Invoke the postLoad lifecycle callbacks and listeners if ( ! empty ( $ metadata -> lifecycleCallbacks [ Events :: postLoad ] ) ) { $ metadata -> invokeLifecycleCallbacks ( Events :: postLoad , $ document ) ; } if ( $ this -> evm -> hasListeners ( Events :: postLoad ) ) { $ this -> evm -> dispatchEvent ( Events :: postLoad , new LifecycleEventArgs ( $ document , $ this -> dm ) ) ; } return $ data ; }
docstring: Hydrate array of MongoDB document data into the given document object.
  
  @param object $document  The document object to hydrate the data into.
  @param array $data The array of document data.
  @param array $hints Any hints to account for during reconstitution/lookup of the document.
  @return array $values The array of hydrated values.
docstring_tokens: Hydrate array of MongoDB document data into the given document object .