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

validateReferences() public method

Validate association targets actually exist.
public validateReferences ( )
    public function validateReferences()
    {
        foreach ($this->referenceMappings as $fieldName) {
            $mapping = $this->mappings[$fieldName];
            if (!empty($mapping['targetDocument']) && !ClassLoader::classExists($mapping['targetDocument'])) {
                throw MappingException::invalidTargetDocumentClass($mapping['targetDocument'], $this->name, $mapping['fieldName']);
            }
        }
    }

Usage Example

 /**
  * 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