Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo::setIdentifier PHP Method

setIdentifier() public method

INTERNAL: Sets the mapped identifier field of this class.
public setIdentifier ( string $identifier )
$identifier string
    public function setIdentifier($identifier)
    {
        $this->identifier = $identifier;
    }

Usage Example

 /**
  * @expectedException \Doctrine\ODM\MongoDB\Mapping\MappingException
  * @expectedExceptionMessage stdClass::id was declared an identifier and must stay this way.
  */
 public function testIdFieldsTypeMustNotBeOverridden()
 {
     $cm = new ClassMetadataInfo('stdClass');
     $cm->setIdentifier('id');
     $cm->mapField(array('fieldName' => 'id', 'type' => 'string'));
 }
ClassMetadataInfo