class Definition

Definition represents a service definition.

Methods

__construct(string $class = null, array $arguments = array())

No description

array
getChanges()

Returns all changes tracked for the Definition object.

$this
setChanges(array $changes)

Sets the tracked changes for the Definition object.

$this
setFactory(string|array $factory)

Sets a factory.

string|array
getFactory()

Gets the factory.

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

Sets the service that this service is decorating.

null|array
getDecoratedService()

Gets the service that this service is decorating.

$this
setClass(string $class)

Sets the service class.

string|null
getClass()

Gets the service class.

$this
setArguments(array $arguments)

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

$this
setProperties(array $properties)

Sets the properties to define when creating the service.

array
getProperties()

Gets the properties to define when creating the service.

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

Sets a specific property.

$this
addArgument(mixed $argument)

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

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

Replaces a specific argument.

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

Sets a specific argument.

array
getArguments()

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

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.

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

Adds a method to call after service initialization.

$this
removeMethodCall(string $method)

Removes a method to call after service initialization.

bool
hasMethodCall(string $method)

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

array
getMethodCalls()

Gets the methods to call after service initialization.

$this
setInstanceofConditionals(array $instanceof)

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

getInstanceofConditionals()

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

$this
setAutoconfigured(bool $autoconfigured)

Sets whether or not instanceof conditionals should be prepended with a global set.

bool
isAutoconfigured()

No description

$this
setTags(array $tags)

Sets tags for this definition.

array
getTags()

Returns all tags.

array
getTag(string $name)

Gets a tag by name.

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

Adds a tag for this definition.

bool
hasTag(string $name)

Whether this definition has a tag with the given name.

$this
clearTag(string $name)

Clears all tags for a given name.

$this
clearTags()

Clears the tags for this definition.

$this
setFile(string $file)

Sets a file to require before creating the service.

string|null
getFile()

Gets the file to require before creating the service.

$this
setShared(bool $shared)

Sets if the service must be shared or not.

bool
isShared()

Whether this service is shared.

$this
setPublic(bool $boolean)

Sets the visibility of this service.

bool
isPublic()

Whether this service is public facing.

$this
setPrivate(bool $boolean)

Sets if this service is private.

bool
isPrivate()

Whether this service is private.

$this
setLazy(bool $lazy)

Sets the lazy flag of this service.

bool
isLazy()

Whether this service is lazy.

$this
setSynthetic(bool $boolean)

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

bool
isSynthetic()

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

$this
setAbstract(bool $boolean)

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

bool
isAbstract()

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

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

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

bool
isDeprecated()

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

string
getDeprecationMessage(string $id)

Message to use if this definition is deprecated.

$this
setConfigurator(string|array $configurator)

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

callable|null
getConfigurator()

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

bool
isAutowired()

Is the definition autowired?

$this
setAutowired(bool $autowired)

Enables/disables autowiring.

array
getBindings()

Gets bindings.

$this
setBindings(array $bindings)

Sets bindings.

addError(string $error)

Add an error that occurred when building this Definition.

array
getErrors()

Returns any errors that occurred while building this Definition.

Details

at line line 56
__construct(string $class = null, array $arguments = array())

Parameters

string $class The service class
array $arguments An array of arguments to pass to the service constructor

at line line 69
array getChanges()

Returns all changes tracked for the Definition object.

Return Value

array An array of changes for this Definition

at line line 81
$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

at line line 95
$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

at line line 113
string|array getFactory()

Gets the factory.

Return Value

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

at line line 129
$this setDecoratedService(null|string $id, null|string $renamedId = null, int $priority)

Sets the service that this service is decorating.

Parameters

null|string $id The decorated service id, use null to remove decoration
null|string $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

at line line 151
null|array getDecoratedService()

Gets the service that this service is decorating.

Return Value

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

at line line 163
$this setClass(string $class)

Sets the service class.

Parameters

string $class The service class

Return Value

$this

at line line 177
string|null getClass()

Gets the service class.

Return Value

string|null The service class

at line line 187
$this setArguments(array $arguments)

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

Parameters

array $arguments

Return Value

$this

at line line 199
$this setProperties(array $properties)

Sets the properties to define when creating the service.

Parameters

array $properties

Return Value

$this

at line line 211
array getProperties()

Gets the properties to define when creating the service.

Return Value

array

at line line 224
$this setProperty(string $name, mixed $value)

Sets a specific property.

Parameters

string $name
mixed $value

Return Value

$this

at line line 238
$this addArgument(mixed $argument)

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

Parameters

mixed $argument An argument

Return Value

$this

at line line 255
$this replaceArgument(int|string $index, mixed $argument)

Replaces a specific argument.

Parameters

int|string $index
mixed $argument

Return Value

$this

Exceptions

OutOfBoundsException When the replaced argument does not exist

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

Sets a specific argument.

Parameters

int|string $key
mixed $value

Return Value

$this

at line line 294
array getArguments()

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

Return Value

array The array of arguments

at line line 308
mixed getArgument(int|string $index)

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

Parameters

int|string $index

Return Value

mixed The argument value

Exceptions

OutOfBoundsException When the argument does not exist

at line line 322
$this setMethodCalls(array $calls = array())

Sets the methods to call after service initialization.

Parameters

array $calls

Return Value

$this

at line line 342
$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

at line line 359
$this removeMethodCall(string $method)

Removes a method to call after service initialization.

Parameters

string $method The method name to remove

Return Value

$this

at line line 378
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

at line line 394
array getMethodCalls()

Gets the methods to call after service initialization.

Return Value

array An array of method calls

at line line 406
$this setInstanceofConditionals(array $instanceof)

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

Parameters

array $instanceof ChildDefinition[]

Return Value

$this

at line line 418
ChildDefinition[] getInstanceofConditionals()

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

Return Value

ChildDefinition[]

at line line 430
$this setAutoconfigured(bool $autoconfigured)

Sets whether or not instanceof conditionals should be prepended with a global set.

Parameters

bool $autoconfigured

Return Value

$this

at line line 442
bool isAutoconfigured()

Return Value

bool

at line line 452
$this setTags(array $tags)

Sets tags for this definition.

Parameters

array $tags

Return Value

$this

at line line 464
array getTags()

Returns all tags.

Return Value

array An array of tags

at line line 476
array getTag(string $name)

Gets a tag by name.

Parameters

string $name The tag name

Return Value

array An array of attributes

at line line 489
$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

at line line 503
bool hasTag(string $name)

Whether this definition has a tag with the given name.

Parameters

string $name

Return Value

bool

at line line 515
$this clearTag(string $name)

Clears all tags for a given name.

Parameters

string $name The tag name

Return Value

$this

at line line 527
$this clearTags()

Clears the tags for this definition.

Return Value

$this

at line line 541
$this setFile(string $file)

Sets a file to require before creating the service.

Parameters

string $file A full pathname to include

Return Value

$this

at line line 555
string|null getFile()

Gets the file to require before creating the service.

Return Value

string|null The full pathname to include

at line line 567
$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

at line line 581
bool isShared()

Whether this service is shared.

Return Value

bool

at line line 593
$this setPublic(bool $boolean)

Sets the visibility of this service.

Parameters

bool $boolean

Return Value

$this

at line line 608
bool isPublic()

Whether this service is public facing.

Return Value

bool

at line line 625
$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

at line line 637
bool isPrivate()

Whether this service is private.

Return Value

bool

at line line 649
$this setLazy(bool $lazy)

Sets the lazy flag of this service.

Parameters

bool $lazy

Return Value

$this

at line line 663
bool isLazy()

Whether this service is lazy.

Return Value

bool

at line line 676
$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

at line line 689
bool isSynthetic()

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

Return Value

bool

at line line 702
$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

at line line 715
bool isAbstract()

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

Return Value

bool

at line line 731
$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

at line line 758
bool isDeprecated()

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

Return Value

bool

at line line 770
string getDeprecationMessage(string $id)

Message to use if this definition is deprecated.

Parameters

string $id Service id relying on this definition

Return Value

string

at line line 782
$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

at line line 800
callable|null getConfigurator()

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

Return Value

callable|null The PHP callable to call

at line line 810
bool isAutowired()

Is the definition autowired?

Return Value

bool

at line line 822
$this setAutowired(bool $autowired)

Enables/disables autowiring.

Parameters

bool $autowired

Return Value

$this

at line line 836
array getBindings()

Gets bindings.

Return Value

array

at line line 852
$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

at line line 870
addError(string $error)

Add an error that occurred when building this Definition.

Parameters

string $error

at line line 880
array getErrors()

Returns any errors that occurred while building this Definition.

Return Value

array