protected function XmlFileLoader::parseConstraints in Plug 7
Parses a collection of "constraint" XML nodes.
Parameters
\SimpleXMLElement $nodes The XML nodes:
Return value
array The Constraint instances
3 calls to XmlFileLoader::parseConstraints()
- XmlFileLoader::loadClassMetadataFromXml in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Mapping/ Loader/ XmlFileLoader.php - Loads the validation metadata from the given XML class description.
- XmlFileLoader::parseOptions in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Mapping/ Loader/ XmlFileLoader.php - Parses a collection of "option" XML nodes.
- XmlFileLoader::parseValues in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Mapping/ Loader/ XmlFileLoader.php - Parses a collection of "value" XML nodes.
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Mapping/ Loader/ XmlFileLoader.php, line 71
Class
- XmlFileLoader
- Loads validation metadata from an XML file.
Namespace
Symfony\Component\Validator\Mapping\LoaderCode
protected function parseConstraints(\SimpleXMLElement $nodes) {
$constraints = array();
foreach ($nodes as $node) {
if (count($node) > 0) {
if (count($node->value) > 0) {
$options = $this
->parseValues($node->value);
}
elseif (count($node->constraint) > 0) {
$options = $this
->parseConstraints($node->constraint);
}
elseif (count($node->option) > 0) {
$options = $this
->parseOptions($node->option);
}
else {
$options = array();
}
}
elseif (strlen((string) $node) > 0) {
$options = trim($node);
}
else {
$options = null;
}
$constraints[] = $this
->newConstraint((string) $node['name'], $options);
}
return $constraints;
}