public function XmlFileLoader::loadClassMetadata in Zircon Profile 8.0
Same name in this branch
- 8.0 vendor/symfony/validator/Mapping/Loader/XmlFileLoader.php \Symfony\Component\Validator\Mapping\Loader\XmlFileLoader::loadClassMetadata()
- 8.0 vendor/symfony/serializer/Mapping/Loader/XmlFileLoader.php \Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader::loadClassMetadata()
Same name and namespace in other branches
- 8 vendor/symfony/serializer/Mapping/Loader/XmlFileLoader.php \Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader::loadClassMetadata()
Load class metadata.
Parameters
ClassMetadataInterface $classMetadata A metadata:
Return value
bool
Overrides LoaderInterface::loadClassMetadata
File
- vendor/
symfony/ serializer/ Mapping/ Loader/ XmlFileLoader.php, line 36
Class
- XmlFileLoader
- Loads XML mapping files.
Namespace
Symfony\Component\Serializer\Mapping\LoaderCode
public function loadClassMetadata(ClassMetadataInterface $classMetadata) {
if (null === $this->classes) {
$this->classes = array();
$xml = $this
->parseFile($this->file);
foreach ($xml->class as $class) {
$this->classes[(string) $class['name']] = $class;
}
}
$attributesMetadata = $classMetadata
->getAttributesMetadata();
if (isset($this->classes[$classMetadata
->getName()])) {
$xml = $this->classes[$classMetadata
->getName()];
foreach ($xml->attribute as $attribute) {
$attributeName = (string) $attribute['name'];
if (isset($attributesMetadata[$attributeName])) {
$attributeMetadata = $attributesMetadata[$attributeName];
}
else {
$attributeMetadata = new AttributeMetadata($attributeName);
$classMetadata
->addAttributeMetadata($attributeMetadata);
}
foreach ($attribute->group as $group) {
$attributeMetadata
->addGroup((string) $group);
}
}
return true;
}
return false;
}