Since: 1.0
Author: Benjamin Eberlei (kontakt@beberlei.de)
Author: Lukas Kahwe Smith (smith@pooteeweet.org)
Inheritance: extends Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory
 public function testGetMapping()
 {
     $cmf = new ClassMetadataFactory($this->dm);
     $cm = new \Doctrine\ODM\CouchDB\Mapping\ClassMetadata('stdClass');
     $cmf->setMetadataFor('stdClass', $cm);
     $this->assertTrue($cmf->hasMetadataFor('stdClass'));
     $this->assertSame($cm, $cmf->getMetadataFor('stdClass'));
 }
 public function testGetAllMetadata()
 {
     $driver = new \Doctrine\ODM\CouchDB\Mapping\Driver\PHPDriver(array(__DIR__));
     $this->dm->getConfiguration()->setMetadataDriverImpl($driver);
     $cmf = new ClassMetadataFactory($this->dm);
     $cm = new \Doctrine\ODM\CouchDB\Mapping\ClassMetadata('stdClass');
     $cmf->setMetadataFor('stdClass', $cm);
     $metadata = $cmf->getAllMetadata();
     $this->assertInternalType('array', $metadata);
 }
Example #3
0
 /**
  * Gets a reference to the entity identified by the given type and identifier
  * without actually loading it, if the entity is not yet loaded.
  *
  * @param string $documentName The name of the entity type.
  * @param mixed $identifier The entity identifier.
  * @return object The entity reference.
  */
 public function getReference($documentName, $identifier)
 {
     $class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\'));
     // Check identity map first, if its already in there just return it.
     if ($document = $this->unitOfWork->tryGetById($identifier)) {
         return $document;
     }
     $document = $this->proxyFactory->getProxy($class->name, $identifier);
     $this->unitOfWork->registerManaged($document, $identifier, null);
     return $document;
 }