load() public méthode

Loads an document by a list of field criteria.
public load ( array $criteria, object $document = null, array $hints = [], integer $lockMode ) : object
$criteria array The criteria by which to load the document.
$document object The document to load the data into. If not specified, a new document is created.
$hints array Hints for document creation.
$lockMode integer
Résultat object The loaded and managed document instance or NULL if the document can not be found.
 /**
  * Generates a closure capable of finalizing a cloned proxy
  *
  * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata
  * @param \Doctrine\ODM\MongoDB\Persisters\DocumentPersister $documentPersister
  * @param \ReflectionProperty                                $reflectionId
  *
  * @return \Closure
  *
  * @throws \Doctrine\ODM\MongoDB\DocumentNotFoundException
  */
 private function createCloner(BaseClassMetadata $classMetadata, DocumentPersister $documentPersister, ReflectionProperty $reflectionId)
 {
     return function (BaseProxy $proxy) use($documentPersister, $classMetadata, $reflectionId) {
         if ($proxy->__isInitialized()) {
             return;
         }
         $proxy->__setInitialized(true);
         $proxy->__setInitializer(null);
         $id = $reflectionId->getValue($proxy);
         $original = $documentPersister->load(array('_id' => $id));
         if (null === $original) {
             throw DocumentNotFoundException::documentNotFound(get_class($proxy), $id);
         }
         foreach ($classMetadata->getReflectionClass()->getProperties() as $reflectionProperty) {
             $propertyName = $reflectionProperty->getName();
             if ($classMetadata->hasField($propertyName) || $classMetadata->hasAssociation($propertyName)) {
                 $reflectionProperty->setAccessible(true);
                 $reflectionProperty->setValue($proxy, $reflectionProperty->getValue($original));
             }
         }
     };
 }