W3cubDocs

/Symfony 4.1

ChildDefinition

class ChildDefinition extends Definition

This definition extends another definition.

Properties

protected $arguments from Definition
$innerServiceId from Definition

Methods

__construct(string $parent)
array getChanges()

Returns all changes tracked for the Definition object.

from Definition
$this setChanges(array $changes)

Sets the tracked changes for the Definition object.

from Definition
$this setFactory(string|array $factory)

Sets a factory.

from Definition
string|array|null getFactory()

Gets the factory.

from Definition
$this setDecoratedService(string|null $id, string|null $renamedId = null, int $priority = 0)

Sets the service that this service is decorating.

from Definition
array|null getDecoratedService()

Gets the service that this service is decorating.

from Definition
$this setClass(string $class)

Sets the service class.

from Definition
string|null getClass()

Gets the service class.

from Definition
$this setArguments(array $arguments)

Sets the arguments to pass to the service constructor/factory method.

from Definition
$this setProperties(array $properties)

Sets the properties to define when creating the service.

from Definition
array getProperties()

Gets the properties to define when creating the service.

from Definition
$this setProperty(string $name, mixed $value)

Sets a specific property.

from Definition
$this addArgument(mixed $argument)

Adds an argument to pass to the service constructor/factory method.

from Definition
$this replaceArgument(int|string $index, mixed $value)

You should always use this method when overwriting existing arguments of the parent definition.

$this setArgument(int|string $key, mixed $value)

Sets a specific argument.

from Definition
array getArguments()

Gets the arguments to pass to the service constructor/factory method.

from Definition
mixed getArgument(int|string $index)

Gets an argument to pass to the service constructor/factory method.

$this setMethodCalls(array $calls = array())

Sets the methods to call after service initialization.

from Definition
$this addMethodCall(string $method, array $arguments = array())

Adds a method to call after service initialization.

from Definition
$this removeMethodCall(string $method)

Removes a method to call after service initialization.

from Definition
bool hasMethodCall(string $method)

Check if the current definition has a given method to call after service initialization.

from Definition
array getMethodCalls()

Gets the methods to call after service initialization.

from Definition
$this setInstanceofConditionals(array $instanceof)
ChildDefinition[] getInstanceofConditionals()

Gets the definition templates to conditionally apply on the current definition, keyed by parent interface/class.

from Definition
$this setAutoconfigured(bool $autoconfigured)
bool isAutoconfigured() from Definition
$this setTags(array $tags)

Sets tags for this definition.

from Definition
array getTags()

Returns all tags.

from Definition
array getTag(string $name)

Gets a tag by name.

from Definition
$this addTag(string $name, array $attributes = array())

Adds a tag for this definition.

from Definition
bool hasTag(string $name)

Whether this definition has a tag with the given name.

from Definition
$this clearTag(string $name)

Clears all tags for a given name.

from Definition
$this clearTags()

Clears the tags for this definition.

from Definition
$this setFile(string $file)

Sets a file to require before creating the service.

from Definition
string|null getFile()

Gets the file to require before creating the service.

from Definition
$this setShared(bool $shared)

Sets if the service must be shared or not.

from Definition
bool isShared()

Whether this service is shared.

from Definition
$this setPublic(bool $boolean)

Sets the visibility of this service.

from Definition
bool isPublic()

Whether this service is public facing.

from Definition
$this setPrivate(bool $boolean)

Sets if this service is private.

from Definition
bool isPrivate()

Whether this service is private.

from Definition
$this setLazy(bool $lazy)

Sets the lazy flag of this service.

from Definition
bool isLazy()

Whether this service is lazy.

from Definition
$this setSynthetic(bool $boolean)

Sets whether this definition is synthetic, that is not constructed by the container, but dynamically injected.

from Definition
bool isSynthetic()

Whether this definition is synthetic, that is not constructed by the container, but dynamically injected.

from Definition
$this setAbstract(bool $boolean)

Whether this definition is abstract, that means it merely serves as a template for other definitions.

from Definition
bool isAbstract()

Whether this definition is abstract, that means it merely serves as a template for other definitions.

from Definition
$this setDeprecated(bool $status = true, string $template = null)

Whether this definition is deprecated, that means it should not be called anymore.

from Definition
bool isDeprecated()

Whether this definition is deprecated, that means it should not be called anymore.

from Definition
string getDeprecationMessage(string $id)

Message to use if this definition is deprecated.

from Definition
$this setConfigurator(string|array $configurator)

Sets a configurator to call after the service is fully initialized.

from Definition
callable|null getConfigurator()

Gets the configurator to call after the service is fully initialized.

from Definition
bool isAutowired()

Is the definition autowired?

from Definition
$this setAutowired(bool $autowired)

Enables/disables autowiring.

from Definition
array|BoundArgument[] getBindings()

Gets bindings.

from Definition
$this setBindings(array $bindings)

Sets bindings.

from Definition
$this addError(string $error)

Add an error that occurred when building this Definition.

from Definition
array getErrors()

Returns any errors that occurred while building this Definition.

from Definition
string getParent()

Returns the Definition to inherit from.

$this setParent(string $parent)

Sets the Definition to inherit from.

Details

__construct(string $parent)

Parameters

string $parent The id of Definition instance to decorate

array getChanges()

Returns all changes tracked for the Definition object.

Return Value

array An array of changes for this Definition

$this setChanges(array $changes)

Sets the tracked changes for the Definition object.

Parameters

array $changes An array of changes for this Definition

Return Value

$this

$this setFactory(string|array $factory)

Sets a factory.

Parameters

string|array $factory A PHP function or an array containing a class/Reference and a method to call

Return Value

$this

string|array|null getFactory()

Gets the factory.

Return Value

string|array|null The PHP function or an array containing a class/Reference and a method to call

$this setDecoratedService(string|null $id, string|null $renamedId = null, int $priority = 0)

Sets the service that this service is decorating.

Parameters

string|null $id The decorated service id, use null to remove decoration
string|null $renamedId The new decorated service id
int $priority The priority of decoration

Return Value

$this

Exceptions

InvalidArgumentException in case the decorated service id and the new decorated service id are equals

array|null getDecoratedService()

Gets the service that this service is decorating.

Return Value

array|null An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated

$this setClass(string $class)

Sets the service class.

Parameters

string $class The service class

Return Value

$this

string|null getClass()

Gets the service class.

Return Value

string|null The service class

$this setArguments(array $arguments)

Sets the arguments to pass to the service constructor/factory method.

Parameters

array $arguments

Return Value

$this

$this setProperties(array $properties)

Sets the properties to define when creating the service.

Parameters

array $properties

Return Value

$this

array getProperties()

Gets the properties to define when creating the service.

Return Value

array

$this setProperty(string $name, mixed $value)

Sets a specific property.

Parameters

string $name
mixed $value

Return Value

$this

$this addArgument(mixed $argument)

Adds an argument to pass to the service constructor/factory method.

Parameters

mixed $argument An argument

Return Value

$this

$this replaceArgument(int|string $index, mixed $value)

You should always use this method when overwriting existing arguments of the parent definition.

If you directly call setArguments() keep in mind that you must follow certain conventions when you want to overwrite the arguments of the parent definition, otherwise your arguments will only be appended.

Parameters

int|string $index
mixed $value

Return Value

$this

Exceptions

InvalidArgumentException when $index isn't an integer

$this setArgument(int|string $key, mixed $value)

Sets a specific argument.

Parameters

int|string $key
mixed $value

Return Value

$this

array getArguments()

Gets the arguments to pass to the service constructor/factory method.

Return Value

array The array of arguments

mixed getArgument(int|string $index)

Gets an argument to pass to the service constructor/factory method.

If replaceArgument() has been used to replace an argument, this method will return the replacement value.

Parameters

int|string $index

Return Value

mixed The argument value

Exceptions

OutOfBoundsException When the argument does not exist

$this setMethodCalls(array $calls = array())

Sets the methods to call after service initialization.

Parameters

array $calls

Return Value

$this

$this addMethodCall(string $method, array $arguments = array())

Adds a method to call after service initialization.

Parameters

string $method The method name to call
array $arguments An array of arguments to pass to the method call

Return Value

$this

Exceptions

InvalidArgumentException on empty $method param

$this removeMethodCall(string $method)

Removes a method to call after service initialization.

Parameters

string $method The method name to remove

Return Value

$this

bool hasMethodCall(string $method)

Check if the current definition has a given method to call after service initialization.

Parameters

string $method The method name to search for

Return Value

bool

array getMethodCalls()

Gets the methods to call after service initialization.

Return Value

array An array of method calls

$this setInstanceofConditionals(array $instanceof)

Parameters

array $instanceof ChildDefinition[]

Return Value

$this

ChildDefinition[] getInstanceofConditionals()

Gets the definition templates to conditionally apply on the current definition, keyed by parent interface/class.

Return Value

ChildDefinition[]

$this setAutoconfigured(bool $autoconfigured)

Parameters

bool $autoconfigured

Return Value

$this

bool isAutoconfigured()

Return Value

bool

$this setTags(array $tags)

Sets tags for this definition.

Parameters

array $tags

Return Value

$this

array getTags()

Returns all tags.

Return Value

array An array of tags

array getTag(string $name)

Gets a tag by name.

Parameters

string $name The tag name

Return Value

array An array of attributes

$this addTag(string $name, array $attributes = array())

Adds a tag for this definition.

Parameters

string $name The tag name
array $attributes An array of attributes

Return Value

$this

bool hasTag(string $name)

Whether this definition has a tag with the given name.

Parameters

string $name

Return Value

bool

$this clearTag(string $name)

Clears all tags for a given name.

Parameters

string $name The tag name

Return Value

$this

$this clearTags()

Clears the tags for this definition.

Return Value

$this

$this setFile(string $file)

Sets a file to require before creating the service.

Parameters

string $file A full pathname to include

Return Value

$this

string|null getFile()

Gets the file to require before creating the service.

Return Value

string|null The full pathname to include

$this setShared(bool $shared)

Sets if the service must be shared or not.

Parameters

bool $shared Whether the service must be shared or not

Return Value

$this

bool isShared()

Whether this service is shared.

Return Value

bool

$this setPublic(bool $boolean)

Sets the visibility of this service.

Parameters

bool $boolean

Return Value

$this

bool isPublic()

Whether this service is public facing.

Return Value

bool

$this setPrivate(bool $boolean)

Sets if this service is private.

When set, the "private" state has a higher precedence than "public". In version 3.4, a "private" service always remains publicly accessible, but triggers a deprecation notice when accessed from the container, so that the service can be made really private in 4.0.

Parameters

bool $boolean

Return Value

$this

bool isPrivate()

Whether this service is private.

Return Value

bool

$this setLazy(bool $lazy)

Sets the lazy flag of this service.

Parameters

bool $lazy

Return Value

$this

bool isLazy()

Whether this service is lazy.

Return Value

bool

$this setSynthetic(bool $boolean)

Sets whether this definition is synthetic, that is not constructed by the container, but dynamically injected.

Parameters

bool $boolean

Return Value

$this

bool isSynthetic()

Whether this definition is synthetic, that is not constructed by the container, but dynamically injected.

Return Value

bool

$this setAbstract(bool $boolean)

Whether this definition is abstract, that means it merely serves as a template for other definitions.

Parameters

bool $boolean

Return Value

$this

bool isAbstract()

Whether this definition is abstract, that means it merely serves as a template for other definitions.

Return Value

bool

$this setDeprecated(bool $status = true, string $template = null)

Whether this definition is deprecated, that means it should not be called anymore.

Parameters

bool $status
string $template Template message to use if the definition is deprecated

Return Value

$this

Exceptions

InvalidArgumentException when the message template is invalid

bool isDeprecated()

Whether this definition is deprecated, that means it should not be called anymore.

Return Value

bool

string getDeprecationMessage(string $id)

Message to use if this definition is deprecated.

Parameters

string $id Service id relying on this definition

Return Value

string

$this setConfigurator(string|array $configurator)

Sets a configurator to call after the service is fully initialized.

Parameters

string|array $configurator A PHP callable

Return Value

$this

callable|null getConfigurator()

Gets the configurator to call after the service is fully initialized.

Return Value

callable|null The PHP callable to call

bool isAutowired()

Is the definition autowired?

Return Value

bool

$this setAutowired(bool $autowired)

Enables/disables autowiring.

Parameters

bool $autowired

Return Value

$this

array|BoundArgument[] getBindings()

Gets bindings.

Return Value

array|BoundArgument[]

$this setBindings(array $bindings)

Sets bindings.

Bindings map $named or FQCN arguments to values that should be injected in the matching parameters (of the constructor, of methods called and of controller actions).

Parameters

array $bindings

Return Value

$this

$this addError(string $error)

Add an error that occurred when building this Definition.

Parameters

string $error

Return Value

$this

array getErrors()

Returns any errors that occurred while building this Definition.

Return Value

array

string getParent()

Returns the Definition to inherit from.

Return Value

string

$this setParent(string $parent)

Sets the Definition to inherit from.

Parameters

string $parent

Return Value

$this

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/DependencyInjection/ChildDefinition.html