W3cubDocs

/Symfony 4.1

FileLoader

abstract class FileLoader extends AbstractLoader

Base loader for loading validation metadata from a file.

Constants

DEFAULT_NAMESPACE

The namespace to load constraints from by default.

Properties

protected $namespaces from AbstractLoader
protected $file

Methods

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.

Details

protected addNamespaceAlias(string $alias, string $namespace)

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');

Parameters

string $alias The alias
string $namespace The PHP namespace

protected Constraint newConstraint(string $name, mixed $options = null)

Creates a new constraint instance for the given constraint name.

Parameters

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

Return Value

Constraint

Exceptions

MappingException If the namespace prefix is undefined

__construct(string $file)

Creates a new loader.

Parameters

string $file The mapping file to load

Exceptions

MappingException If the file does not exist or is not readable

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Validator/Mapping/Loader/FileLoader.html