Doctrine\ODM\PHPCR\Mapping\ClassMetadata::mapId PHP Method

mapId() public method

public mapId ( array $mapping, ClassMetadata $inherited = null )
$mapping array
$inherited ClassMetadata
    public function mapId(array $mapping, ClassMetadata $inherited = null)
    {
        if (isset($mapping['id']) && $mapping['id'] === true) {
            $mapping['type'] = 'string';
            $this->setIdentifier($mapping['fieldName']);
            if (isset($mapping['strategy'])) {
                $this->setIdGenerator($mapping['strategy']);
            }
        }
        $this->validateAndCompleteFieldMapping($mapping, $inherited, false, false);
    }

Usage Example

Beispiel #1
0
 public function setUp()
 {
     if (!class_exists('Jackalope\\Factory', true)) {
         $this->markTestSkipped('The Node needs to be properly mocked/stubbed. Remove dependency to Jackalope');
     }
     $this->factory = new Factory();
     $this->session = $this->getMock('Jackalope\\Session', array(), array($this->factory), '', false);
     $this->objectManager = $this->getMock('Jackalope\\ObjectManager', array(), array($this->factory), '', false);
     $this->type = 'Doctrine\\Tests\\ODM\\PHPCR\\UoWUser';
     $this->dm = DocumentManager::create($this->session);
     $this->uow = new UnitOfWork($this->dm);
     $cmf = $this->dm->getMetadataFactory();
     $metadata = new ClassMetadata($this->type);
     $metadata->initializeReflection($cmf->getReflectionService());
     $metadata->mapId(array('fieldName' => 'id', 'id' => true));
     $metadata->idGenerator = ClassMetadata::GENERATOR_TYPE_ASSIGNED;
     $metadata->mapField(array('fieldName' => 'username', 'type' => 'string'));
     $cmf->setMetadataFor($this->type, $metadata);
 }
All Usage Examples Of Doctrine\ODM\PHPCR\Mapping\ClassMetadata::mapId
ClassMetadata