protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
    {
        if ($parent) {
            $this->addInheritedDocumentOptions($class, $parent);
            $this->addInheritedFields($class, $parent);
        }

        if ($this->getDriver()) {
            $this->getDriver()->loadMetadataForClass($class->getName(), $class);
        }

        // once we loaded the metadata of this class, we might have to merge in the mixins of the parent.
        if ($parent && $class->getInheritMixins()) {
            $class->setMixins(array_merge($parent->getMixins(), $class->getMixins()));
        }

        if ($this->evm->hasListeners(Event::loadClassMetadata)) {
            $eventArgs = new LoadClassMetadataEventArgs($class, $this->dm);
            $this->evm->dispatchEvent(Event::loadClassMetadata, $eventArgs);
        }

        $this->validateRuntimeMetadata($class, $parent);
        $class->setParentClasses($this->getParentClasses($class->name));
    }