public function loadClassMetadata(ClassMetadataInterface $classMetadata)
{
if (null === $this->classes) {
- $this->classes = array();
- $xml = $this->parseFile($this->file);
+ $this->classes = $this->getClassesFromXml();
+ }
- foreach ($xml->class as $class) {
- $this->classes[(string) $class['name']] = $class;
- }
+ if (!$this->classes) {
+ return false;
}
$attributesMetadata = $classMetadata->getAttributesMetadata();
foreach ($attribute->group as $group) {
$attributeMetadata->addGroup((string) $group);
}
+
+ if (isset($attribute['max-depth'])) {
+ $attributeMetadata->setMaxDepth((int) $attribute['max-depth']);
+ }
}
return true;
return false;
}
+ /**
+ * Return the names of the classes mapped in this file.
+ *
+ * @return string[] The classes names
+ */
+ public function getMappedClasses()
+ {
+ if (null === $this->classes) {
+ $this->classes = $this->getClassesFromXml();
+ }
+
+ return array_keys($this->classes);
+ }
+
/**
* Parses a XML File.
*
return simplexml_import_dom($dom);
}
+
+ private function getClassesFromXml()
+ {
+ $xml = $this->parseFile($this->file);
+ $classes = array();
+
+ foreach ($xml->class as $class) {
+ $classes[(string) $class['name']] = $class;
+ }
+
+ return $classes;
+ }
}