YamlFileLoader
extends FileLoader
in package
YamlFileLoader loads YAML files service definitions.
Tags
Table of Contents
Constants
- ANONYMOUS_ID_REGEXP = '/^\.\d+_[^~]*+~[._a-zA-Z\d]{7}$/'
- DEFAULTS_KEYWORDS = ['public' => 'public', 'tags' => 'tags', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind']
- INSTANCEOF_KEYWORDS = ['shared' => 'shared', 'lazy' => 'lazy', 'public' => 'public', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'autowire' => 'autowire', 'bind' => 'bind', 'constructor' => 'constructor']
- PROTOTYPE_KEYWORDS = ['resource' => 'resource', 'namespace' => 'namespace', 'exclude' => 'exclude', 'parent' => 'parent', 'shared' => 'shared', 'lazy' => 'lazy', 'public' => 'public', 'abstract' => 'abstract', 'deprecated' => 'deprecated', 'factory' => 'factory', 'arguments' => 'arguments', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind', 'constructor' => 'constructor']
- SERVICE_KEYWORDS = ['alias' => 'alias', 'parent' => 'parent', 'class' => 'class', 'shared' => 'shared', 'synthetic' => 'synthetic', 'lazy' => 'lazy', 'public' => 'public', 'abstract' => 'abstract', 'deprecated' => 'deprecated', 'factory' => 'factory', 'file' => 'file', 'arguments' => 'arguments', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'decorates' => 'decorates', 'decoration_inner_name' => 'decoration_inner_name', 'decoration_priority' => 'decoration_priority', 'decoration_on_invalid' => 'decoration_on_invalid', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind', 'constructor' => 'constructor']
Properties
- $aliases : array<string, Alias>
- $autoRegisterAliasesForSinglyImplementedInterfaces : mixed
- $container : mixed
- $env : mixed
- $instanceof : mixed
- $interfaces : mixed
- $isLoadingInstanceof : mixed
- $loading : mixed
- $locator : mixed
- $resolver : mixed
- $singlyImplemented : mixed
- $anonymousServicesCount : int
- $anonymousServicesSuffix : string
- $yamlParser : Parser
Methods
- __construct() : mixed
- getLocator() : FileLocatorInterface
- Returns the file locator used by this loader.
- getResolver() : LoaderResolverInterface
- Gets the loader resolver.
- import() : mixed
- Imports a resource.
- load() : mixed
- Loads a resource.
- registerAliasesForSinglyImplementedInterfaces() : void
- registerClasses() : void
- Registers a set of classes as services using PSR-4 for discovery.
- resolve() : LoaderInterface
- Finds a loader able to load an imported resource.
- setCurrentDir() : void
- Sets the current directory.
- setResolver() : void
- Sets the loader resolver.
- supports() : bool
- Returns whether this class supports the given resource.
- loadFile() : array<string|int, mixed>|null
- Loads a YAML file.
- setDefinition() : void
- Registers a definition in the container with its instanceof-conditionals.
- checkDefinition() : void
- isUsingShortSyntax() : bool
- loadContent() : void
- loadFromExtensions() : void
- parseCallable() : string|array<string|int, mixed>|Reference
- parseDefaults() : array<string|int, mixed>
- parseDefinition() : Definition|Alias|null
- parseDefinitions() : void
- parseImports() : void
- resolveServices() : mixed
- validate() : array<string|int, mixed>|null
- Validates a YAML file.
- validateAttributes() : void
Constants
ANONYMOUS_ID_REGEXP
public
mixed
ANONYMOUS_ID_REGEXP
= '/^\.\d+_[^~]*+~[._a-zA-Z\d]{7}$/'
DEFAULTS_KEYWORDS
private
mixed
DEFAULTS_KEYWORDS
= ['public' => 'public', 'tags' => 'tags', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind']
INSTANCEOF_KEYWORDS
private
mixed
INSTANCEOF_KEYWORDS
= ['shared' => 'shared', 'lazy' => 'lazy', 'public' => 'public', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'autowire' => 'autowire', 'bind' => 'bind', 'constructor' => 'constructor']
PROTOTYPE_KEYWORDS
private
mixed
PROTOTYPE_KEYWORDS
= ['resource' => 'resource', 'namespace' => 'namespace', 'exclude' => 'exclude', 'parent' => 'parent', 'shared' => 'shared', 'lazy' => 'lazy', 'public' => 'public', 'abstract' => 'abstract', 'deprecated' => 'deprecated', 'factory' => 'factory', 'arguments' => 'arguments', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind', 'constructor' => 'constructor']
SERVICE_KEYWORDS
private
mixed
SERVICE_KEYWORDS
= ['alias' => 'alias', 'parent' => 'parent', 'class' => 'class', 'shared' => 'shared', 'synthetic' => 'synthetic', 'lazy' => 'lazy', 'public' => 'public', 'abstract' => 'abstract', 'deprecated' => 'deprecated', 'factory' => 'factory', 'file' => 'file', 'arguments' => 'arguments', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'decorates' => 'decorates', 'decoration_inner_name' => 'decoration_inner_name', 'decoration_priority' => 'decoration_priority', 'decoration_on_invalid' => 'decoration_on_invalid', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind', 'constructor' => 'constructor']
Properties
$aliases
protected
array<string, Alias>
$aliases
= []
$autoRegisterAliasesForSinglyImplementedInterfaces
protected
mixed
$autoRegisterAliasesForSinglyImplementedInterfaces
= false
$container
protected
mixed
$container
$env
protected
mixed
$env
$instanceof
protected
mixed
$instanceof
= []
$interfaces
protected
mixed
$interfaces
= []
$isLoadingInstanceof
protected
mixed
$isLoadingInstanceof
= false
$loading
protected
static mixed
$loading
= []
$locator
protected
mixed
$locator
$resolver
protected
mixed
$resolver
$singlyImplemented
protected
mixed
$singlyImplemented
= []
$anonymousServicesCount
private
int
$anonymousServicesCount
$anonymousServicesSuffix
private
string
$anonymousServicesSuffix
$yamlParser
private
Parser
$yamlParser
Methods
__construct()
public
__construct(ContainerBuilder $container, FileLocatorInterface $locator[, string|null $env = null ]) : mixed
Parameters
- $container : ContainerBuilder
- $locator : FileLocatorInterface
- $env : string|null = null
getLocator()
Returns the file locator used by this loader.
public
getLocator() : FileLocatorInterface
Return values
FileLocatorInterfacegetResolver()
Gets the loader resolver.
public
getResolver() : LoaderResolverInterface
Return values
LoaderResolverInterfaceimport()
Imports a resource.
public
import(mixed $resource[, string|null $type = null ][, bool|string $ignoreErrors = false ][, string|null $sourceResource = null ][, mixed $exclude = null ]) : mixed
Parameters
- $resource : mixed
-
A Resource
- $type : string|null = null
-
The resource type or null if unknown
- $ignoreErrors : bool|string = false
-
Whether errors should be ignored; pass "not_found" to ignore only when the loaded resource is not found
- $sourceResource : string|null = null
-
The original resource importing the new resource
- $exclude : mixed = null
-
Glob patterns to exclude from the import
load()
Loads a resource.
public
load(mixed $resource[, string|null $type = null ]) : mixed
Parameters
- $resource : mixed
- $type : string|null = null
registerAliasesForSinglyImplementedInterfaces()
public
registerAliasesForSinglyImplementedInterfaces() : void
registerClasses()
Registers a set of classes as services using PSR-4 for discovery.
public
registerClasses(Definition $prototype, string $namespace, string $resource[, string|array<string|int, string>|null $exclude = null ]) : void
Parameters
- $prototype : Definition
-
A definition to use as template
- $namespace : string
-
The namespace prefix of classes in the scanned directory
- $resource : string
-
The directory to look for classes, glob-patterns allowed
- $exclude : string|array<string|int, string>|null = null
-
A globbed path of files to exclude or an array of globbed paths of files to exclude
resolve()
Finds a loader able to load an imported resource.
public
resolve(mixed $resource[, string|null $type = null ]) : LoaderInterface
Parameters
- $resource : mixed
- $type : string|null = null
Tags
Return values
LoaderInterfacesetCurrentDir()
Sets the current directory.
public
setCurrentDir(string $dir) : void
Parameters
- $dir : string
setResolver()
Sets the loader resolver.
public
setResolver(LoaderResolverInterface $resolver) : void
Parameters
- $resolver : LoaderResolverInterface
supports()
Returns whether this class supports the given resource.
public
supports(mixed $resource[, string|null $type = null ]) : bool
Parameters
- $resource : mixed
-
A resource
- $type : string|null = null
Return values
boolloadFile()
Loads a YAML file.
protected
loadFile(string $file) : array<string|int, mixed>|null
Parameters
- $file : string
Tags
Return values
array<string|int, mixed>|nullsetDefinition()
Registers a definition in the container with its instanceof-conditionals.
protected
setDefinition(string $id, Definition $definition) : void
Parameters
- $id : string
- $definition : Definition
checkDefinition()
private
checkDefinition(string $id, array<string|int, mixed> $definition, string $file) : void
Parameters
- $id : string
- $definition : array<string|int, mixed>
- $file : string
isUsingShortSyntax()
private
isUsingShortSyntax(array<string|int, mixed> $service) : bool
Parameters
- $service : array<string|int, mixed>
Return values
boolloadContent()
private
loadContent(array<string|int, mixed> $content, string $path) : void
Parameters
- $content : array<string|int, mixed>
- $path : string
loadFromExtensions()
private
loadFromExtensions(array<string|int, mixed> $content) : void
Parameters
- $content : array<string|int, mixed>
parseCallable()
private
parseCallable(mixed $callable, string $parameter, string $id, string $file) : string|array<string|int, mixed>|Reference
Parameters
- $callable : mixed
- $parameter : string
- $id : string
- $file : string
Tags
Return values
string|array<string|int, mixed>|ReferenceparseDefaults()
private
parseDefaults(array<string|int, mixed> &$content, string $file) : array<string|int, mixed>
Parameters
- $content : array<string|int, mixed>
- $file : string
Tags
Return values
array<string|int, mixed>parseDefinition()
private
parseDefinition(string $id, array<string|int, mixed>|string|null $service, string $file, array<string|int, mixed> $defaults[, bool $return = false ][, bool $trackBindings = true ]) : Definition|Alias|null
Parameters
- $id : string
- $service : array<string|int, mixed>|string|null
- $file : string
- $defaults : array<string|int, mixed>
- $return : bool = false
- $trackBindings : bool = true
Tags
Return values
Definition|Alias|nullparseDefinitions()
private
parseDefinitions(array<string|int, mixed> $content, string $file[, bool $trackBindings = true ]) : void
Parameters
- $content : array<string|int, mixed>
- $file : string
- $trackBindings : bool = true
parseImports()
private
parseImports(array<string|int, mixed> $content, string $file) : void
Parameters
- $content : array<string|int, mixed>
- $file : string
resolveServices()
private
resolveServices(mixed $value, string $file[, bool $isParameter = false ]) : mixed
Parameters
- $value : mixed
- $file : string
- $isParameter : bool = false
validate()
Validates a YAML file.
private
validate(mixed $content, string $file) : array<string|int, mixed>|null
Parameters
- $content : mixed
- $file : string
Tags
Return values
array<string|int, mixed>|nullvalidateAttributes()
private
validateAttributes(string $message, array<string|int, mixed> $attributes[, array<string|int, mixed> $path = [] ]) : void
Parameters
- $message : string
- $attributes : array<string|int, mixed>
- $path : array<string|int, mixed> = []