setIdGenerator() публичный Метод

Sets the ID generator used to generate IDs for instances of this class.
public setIdGenerator ( AbstractIdGenerator $generator )
$generator AbstractIdGenerator
Пример #1
0
 /**
  * Completes the ID generator mapping. If "auto" is specified we choose the generator
  * most appropriate.
  *
  * @param Doctrine\OXM\Mapping\ClassMetadataInfo $class
  */
 private function completeIdGeneratorMapping(ClassMetadataInfo $class)
 {
     $idGenType = $class->generatorType;
     if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) {
         $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE);
     }
     // Create & assign an appropriate ID generator instance
     switch ($class->generatorType) {
         case ClassMetadataInfo::GENERATOR_TYPE_INCREMENT:
             throw new OXMException("Increment generator type not implemented yet");
             break;
         case ClassMetadataInfo::GENERATOR_TYPE_NONE:
             $class->setIdGenerator(new \Doctrine\OXM\Id\AssignedGenerator());
             break;
         case ClassMetadataInfo::GENERATOR_TYPE_UUID:
             $class->setIdGenerator(new \Doctrine\OXM\Id\UuidGenerator());
             break;
         default:
             throw new OXMException("Unknown generator type: " . $class->generatorType);
     }
 }