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/validator/Mapping/Loader/XmlFileLoader.php \Symfony\Component\Validator\Mapping\Loader\XmlFileLoader::loadClassMetadata()
Loads validation metadata into a {@link ClassMetadata} instance.
Parameters
ClassMetadata $metadata The metadata to load:
Return value
bool Whether the loader succeeded
Overrides LoaderInterface::loadClassMetadata
File
- vendor/
symfony/ validator/ Mapping/ Loader/ XmlFileLoader.php, line 35
Class
- XmlFileLoader
- Loads validation metadata from an XML file.
Namespace
Symfony\Component\Validator\Mapping\LoaderCode
public function loadClassMetadata(ClassMetadata $metadata) {
if (null === $this->classes) {
// This method may throw an exception. Do not modify the class'
// state before it completes
$xml = $this
->parseFile($this->file);
$this->classes = array();
foreach ($xml->namespace as $namespace) {
$this
->addNamespaceAlias((string) $namespace['prefix'], trim((string) $namespace));
}
foreach ($xml->class as $class) {
$this->classes[(string) $class['name']] = $class;
}
}
if (isset($this->classes[$metadata
->getClassName()])) {
$classDescription = $this->classes[$metadata
->getClassName()];
$this
->loadClassMetadataFromXml($metadata, $classDescription);
return true;
}
return false;
}