Since: 1.0
Author: Jonathan H. Wage (jonwage@gmail.com)
Author: Roman Borschel (roman@code-factory.org)
Author: Giorgio Sironi (piccoloprincipeazzurro@gmail.com)
Ejemplo n.º 1
0
 /**
  * Gets a reference to the document identified by the given type and identifier
  * without actually loading it.
  *
  * If partial objects are allowed, this method will return a partial object that only
  * has its identifier populated. Otherwise a proxy is returned that automatically
  * loads itself on first access.
  *
  * @param string $documentName
  * @param string|object $identifier
  * @return mixed|object The document reference.
  */
 public function getReference($documentName, $identifier)
 {
     /* @var $class \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo */
     $class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\'));
     // Check identity map first, if its already in there just return it.
     if ($document = $this->unitOfWork->tryGetById($identifier, $class)) {
         return $document;
     }
     $document = $this->proxyFactory->getProxy($class->name, array($class->identifier => $identifier));
     $this->unitOfWork->registerManaged($document, $identifier, array());
     return $document;
 }
 /**
  * @dataProvider provideWarmerNotExecuted
  */
 public function testWarmerNotExecuted($autoGenerate)
 {
     $this->container->setParameter('doctrine_mongodb.odm.auto_generate_proxy_classes', $autoGenerate);
     $this->proxyMock->expects($this->exactly(0))->method('generateProxyClasses');
     $this->warmer->warmUp('meh');
 }