class XmlFileLoader extends FileLoader
Loads validation metadata from an XML file.
DEFAULT_NAMESPACE | The namespace to load constraints from by default. |
protected | $namespaces | from AbstractLoader | |
protected | $file | from FileLoader | |
protected SimpleXMLElement[]|null | $classes | The XML nodes of the mapping file. |
addNamespaceAlias(string $alias, string $namespace) Adds a namespace alias. | from AbstractLoader | |
Constraint | newConstraint(string $name, mixed $options = null) Creates a new constraint instance for the given constraint name. | from AbstractLoader |
__construct(string $file) Creates a new loader. | from FileLoader | |
bool | loadClassMetadata(ClassMetadata $metadata) Loads validation metadata into a {@link ClassMetadata} instance. | |
string[] | getMappedClasses() Return the names of the classes mapped in this file. | |
array | parseConstraints(SimpleXMLElement $nodes) Parses a collection of "constraint" XML nodes. | |
array | parseValues(SimpleXMLElement $nodes) Parses a collection of "value" XML nodes. | |
array | parseOptions(SimpleXMLElement $nodes) Parses a collection of "option" XML nodes. | |
SimpleXMLElement | parseFile(string $path) Loads the XML class descriptions from the given file. |
Adds a namespace alias.
The namespace alias can be used to reference constraints from specific namespaces in {@link newConstraint()}:
$this->addNamespaceAlias('mynamespace', '\\Acme\\Package\\Constraints\\');
$constraint = $this->newConstraint('mynamespace:NotNull');
string | $alias | The alias |
string | $namespace | The PHP namespace |
Creates a new constraint instance for the given constraint name.
string | $name | The constraint name. Either a constraint relative to the default constraint namespace, or a fully qualified class name. Alternatively, the constraint may be preceded by a namespace alias and a colon. The namespace alias must have been defined using {@link addNamespaceAlias()}. |
mixed | $options | The constraint options |
Constraint |
MappingException | If the namespace prefix is undefined |
Creates a new loader.
string | $file | The mapping file to load |
MappingException | If the file does not exist or is not readable |
Loads validation metadata into a {@link ClassMetadata} instance.
ClassMetadata | $metadata |
bool | Whether the loader succeeded |
Return the names of the classes mapped in this file.
string[] | The classes names |
Parses a collection of "constraint" XML nodes.
SimpleXMLElement | $nodes | The XML nodes |
array | The Constraint instances |
Parses a collection of "value" XML nodes.
SimpleXMLElement | $nodes | The XML nodes |
array | The values |
Parses a collection of "option" XML nodes.
SimpleXMLElement | $nodes | The XML nodes |
array | The options |
Loads the XML class descriptions from the given file.
string | $path | The path of the XML file |
SimpleXMLElement | The class descriptions |
MappingException | If the file could not be loaded |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.html