Doctrine\ODM\PHPCR\Mapping\ClassMetadata::validateIdentifier PHP 메소드

validateIdentifier() 공개 메소드

Validate Identifier mapping, determine the strategy if none is explicitly set.
public validateIdentifier ( )
    public function validateIdentifier()
    {
        if (!$this->isMappedSuperclass) {
            if ($this->isIdGeneratorNone()) {
                $this->determineIdStrategy();
            }
            switch ($this->idGenerator) {
                case self::GENERATOR_TYPE_PARENT:
                    if (!($this->parentMapping && $this->nodename)) {
                        throw MappingException::identifierRequired($this->name, 'parent and nodename');
                    }
                    break;
                case self::GENERATOR_TYPE_AUTO:
                    if (!$this->parentMapping) {
                        throw MappingException::identifierRequired($this->name, 'parent');
                    }
                    break;
                case self::GENERATOR_TYPE_REPOSITORY:
                    if (!$this->customRepositoryClassName) {
                        throw MappingException::repositoryRequired($this->name, $this->customRepositoryClassName);
                    }
                    break;
                default:
                    if (!$this->identifier) {
                        throw MappingException::identifierRequired($this->name, 'identifier');
                    }
                    break;
            }
        }
    }

Usage Example

예제 #1
0
 /**
  * Validate runtime metadata is correctly defined.
  *
  * @param ClassMetadata $class
  * @param $parent
  * @throws MappingException
  */
 protected function validateRuntimeMetadata($class, $parent)
 {
     if (!$class->reflClass) {
         // only validate if there is a reflection class instance
         return;
     }
     $class->validateIdentifier();
     $class->validateReferences();
     $class->validateLifecycleCallbacks($this->getReflectionService());
     $class->validateTranslatables();
     // verify inheritance
     // TODO
 }
ClassMetadata