YamlFileLoader
extends FileLoader
in package
Loads validation metadata from a YAML file.
Tags
Table of Contents
- DEFAULT_NAMESPACE = '\\Symfony\\Component\\Validator\\Constraints\\'
- The namespace to load constraints from by default.
- $classes : array<string|int, mixed>
- An array of YAML class descriptions.
- $file : mixed
- $namespaces : mixed
- $yamlParser : Parser
- Caches the used YAML parser.
- __construct() : mixed
- Creates a new loader.
- getMappedClasses() : array<string|int, string>
- Return the names of the classes mapped in this file.
- loadClassMetadata() : mixed
- {@inheritdoc}
- addNamespaceAlias() : mixed
- Adds a namespace alias.
- newConstraint() : Constraint
- Creates a new constraint instance for the given constraint name.
- parseNodes() : array<string|int, mixed>
- Parses a collection of YAML nodes.
- loadClassesFromYaml() : mixed
- loadClassMetadataFromYaml() : mixed
- parseFile() : array<string|int, mixed>
- Loads the YAML class descriptions from the given file.
Constants
DEFAULT_NAMESPACE
The namespace to load constraints from by default.
public
mixed
DEFAULT_NAMESPACE
= '\\Symfony\\Component\\Validator\\Constraints\\'
Properties
$classes
An array of YAML class descriptions.
protected
array<string|int, mixed>
$classes
= null
$file
protected
mixed
$file
$namespaces
protected
mixed
$namespaces
= []
$yamlParser
Caches the used YAML parser.
private
Parser
$yamlParser
Methods
__construct()
Creates a new loader.
public
__construct(string $file) : mixed
Parameters
- $file : string
-
The mapping file to load
Tags
Return values
mixed —getMappedClasses()
Return the names of the classes mapped in this file.
public
getMappedClasses() : array<string|int, string>
Return values
array<string|int, string> —The classes names
loadClassMetadata()
{@inheritdoc}
public
loadClassMetadata(ClassMetadata $metadata) : mixed
Parameters
- $metadata : ClassMetadata
Return values
mixed —addNamespaceAlias()
Adds a namespace alias.
protected
addNamespaceAlias(string $alias, string $namespace) : mixed
The namespace alias can be used to reference constraints from specific namespaces in :
$this->addNamespaceAlias('mynamespace', '\\Acme\\Package\\Constraints\\');
$constraint = $this->newConstraint('mynamespace:NotNull');
Parameters
- $alias : string
-
The alias
- $namespace : string
-
The PHP namespace
Return values
mixed —newConstraint()
Creates a new constraint instance for the given constraint name.
protected
newConstraint(string $name[, mixed $options = null ]) : Constraint
Parameters
- $name : string
-
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 .
- $options : mixed = null
-
The constraint options
Tags
Return values
Constraint —parseNodes()
Parses a collection of YAML nodes.
protected
parseNodes(array<string|int, mixed> $nodes) : array<string|int, mixed>
Parameters
- $nodes : array<string|int, mixed>
-
The YAML nodes
Return values
array<string|int, mixed> —An array of values or Constraint instances
loadClassesFromYaml()
private
loadClassesFromYaml() : mixed
Return values
mixed —loadClassMetadataFromYaml()
private
loadClassMetadataFromYaml(ClassMetadata $metadata, array<string|int, mixed> $classDescription) : mixed
Parameters
- $metadata : ClassMetadata
- $classDescription : array<string|int, mixed>
Return values
mixed —parseFile()
Loads the YAML class descriptions from the given file.
private
parseFile(string $path) : array<string|int, mixed>
Parameters
- $path : string