Documentation

YamlFileLoader extends FileLoader
in package

YamlFileLoader loads YAML files service definitions.

Tags
author

Fabien Potencier fabien@symfony.com

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

$autoRegisterAliasesForSinglyImplementedInterfaces

protected mixed $autoRegisterAliasesForSinglyImplementedInterfaces = false

$isLoadingInstanceof

protected mixed $isLoadingInstanceof = false

$resolver

protected mixed $resolver

$singlyImplemented

protected mixed $singlyImplemented = []

$anonymousServicesSuffix

private string $anonymousServicesSuffix

Methods

import()

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
throws
LoaderLoadException

If no loader is found

Return values
LoaderInterface

setCurrentDir()

Sets the current directory.

public setCurrentDir(string $dir) : void
Parameters
$dir : string

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
bool

loadFile()

Loads a YAML file.

protected loadFile(string $file) : array<string|int, mixed>|null
Parameters
$file : string
Tags
throws
InvalidArgumentException

when the given file is not a local file or when it does not exist

Return values
array<string|int, mixed>|null

setDefinition()

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
bool

loadContent()

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
throws
InvalidArgumentException

When errors occur

Return values
string|array<string|int, mixed>|Reference

parseDefaults()

private parseDefaults(array<string|int, mixed> &$content, string $file) : array<string|int, mixed>
Parameters
$content : array<string|int, mixed>
$file : string
Tags
throws
InvalidArgumentException
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
throws
InvalidArgumentException

When tags are invalid

Return values
Definition|Alias|null

parseDefinitions()

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
throws
InvalidArgumentException

When service file is not valid

Return values
array<string|int, mixed>|null

validateAttributes()

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> = []

        
On this page

Search results