DefinitionDecorator
class DefinitionDecorator extends Definition
This definition decorates another definition.
Methods
__construct(string $parent) | ||
$this | setFactory($callable) Sets a factory. | |
string|array | getFactory() Gets the factory. | from Definition |
$this | setFactoryClass($class) Sets the name of the class that acts as a factory using the factory method, which will be invoked statically. | |
string|null | getFactoryClass($triggerDeprecationError = true) deprecated Gets the factory class. | from Definition |
$this | setFactoryMethod($method) Sets the factory method able to create an instance of this class. | |
$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 decorates this service. | from Definition |
string|null | getFactoryMethod($triggerDeprecationError = true) deprecated Gets the factory method. | from Definition |
$this | setFactoryService($service, $triggerDeprecationError = true) Sets the name of the service that acts as a factory using the factory method. | |
string|null | getFactoryService($triggerDeprecationError = true) deprecated Gets the factory service id. | from Definition |
$this | setClass(string $class) Sets the service class. | |
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 |
setProperties(array $properties) | from Definition | |
getProperties() | from Definition | |
setProperty($name, $value) | from Definition | |
$this | addArgument(mixed $argument) Adds an argument to pass to the service constructor/factory method. | from Definition |
$this | replaceArgument(int $index, mixed $value) You should always use this method when overwriting existing arguments of the parent definition. | |
array | getArguments() Gets the arguments to pass to the service constructor/factory method. | from Definition |
mixed | getArgument(int $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 | 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. | |
string|null | getFile() Gets the file to require before creating the service. | from Definition |
Definition | setShared(bool $shared) Sets if the service must be shared or not. | from Definition |
bool | isShared() Whether this service is shared. | from Definition |
$this | setScope($scope, $triggerDeprecationError = true) deprecated Sets the scope of the service. | from Definition |
string | getScope($triggerDeprecationError = true) deprecated Returns the scope of the service. | from Definition |
$this | setPublic(bool $boolean) Sets the visibility of this service. | |
bool | isPublic() Whether this service is public facing. | from Definition |
$this | setSynchronized($boolean, $triggerDeprecationError = true) deprecated Sets the synchronized flag of this service. | from Definition |
bool | isSynchronized($triggerDeprecationError = true) deprecated Whether this service is synchronized. | from Definition |
$this | setLazy($boolean) Sets the lazy flag of this service. | |
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 |
Definition | setDeprecated($boolean = 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. | from Definition |
string | getDeprecationMessage(string $id) Message to use if this definition is deprecated. | from Definition |
$this | setConfigurator(callable $callable) 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. | from Definition |
Definition | setAutowiringTypes(array $types) Sets types that will default to this definition. | from Definition |
bool | isAutowired() Is the definition autowired? | from Definition |
Definition | setAutowired(bool $autowired) Sets autowired. | |
string[] | getAutowiringTypes() Gets autowiring types that will default to this definition. | from Definition |
Definition | addAutowiringType(string $type) Adds a type that will default to this definition. | from Definition |
Definition | removeAutowiringType(string $type) Removes a type. | from Definition |
bool | hasAutowiringType(string $type) Will this definition default for the given type? | from Definition |
string | getParent() Returns the Definition being decorated. | |
array | getChanges() Returns all changes tracked for the Definition object. |
Details
__construct(string $parent)
Parameters
string | $parent | The id of Definition instance to decorate |
$this setFactory($callable)
Sets a factory.
Parameters
$callable |
Return Value
$this |
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 |
$this setFactoryClass($class)
Sets the name of the class that acts as a factory using the factory method, which will be invoked statically.
Parameters
$class |
Return Value
$this |
string|null getFactoryClass($triggerDeprecationError = true) deprecated
deprecated
Gets the factory class.
Parameters
$triggerDeprecationError |
Return Value
string|null | The factory class name |
$this setFactoryMethod($method)
Sets the factory method able to create an instance of this class.
Parameters
$method |
Return Value
$this |
$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. |
null|array getDecoratedService()
Gets the service that decorates this service.
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 |
string|null getFactoryMethod($triggerDeprecationError = true) deprecated
deprecated
Gets the factory method.
Parameters
$triggerDeprecationError |
Return Value
string|null | The factory method name |
$this setFactoryService($service, $triggerDeprecationError = true)
Sets the name of the service that acts as a factory using the factory method.
Parameters
$service | ||
$triggerDeprecationError |
Return Value
$this |
string|null getFactoryService($triggerDeprecationError = true) deprecated
deprecated
Gets the factory service id.
Parameters
$triggerDeprecationError |
Return Value
string|null | The factory service id |
$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 | An array of arguments |
Return Value
$this |
setProperties(array $properties)
Parameters
array | $properties |
getProperties()
setProperty($name, $value)
Parameters
$name | ||
$value |
$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 $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 | $index | |
mixed | $value |
Return Value
$this |
Exceptions
InvalidArgumentException | when $index isn't an integer |
array getArguments()
Gets the arguments to pass to the service constructor/factory method.
Return Value
array | The array of arguments |
mixed getArgument(int $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 | $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 | An array of method 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 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 |
Definition 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
Definition | The current instance |
bool isShared()
Whether this service is shared.
Return Value
bool |
$this setScope($scope, $triggerDeprecationError = true) deprecated
deprecated
Sets the scope of the service.
Parameters
$scope | ||
$triggerDeprecationError |
Return Value
$this |
string getScope($triggerDeprecationError = true) deprecated
deprecated
Returns the scope of the service.
Parameters
$triggerDeprecationError |
Return Value
string |
$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 setSynchronized($boolean, $triggerDeprecationError = true) deprecated
deprecated
Sets the synchronized flag of this service.
Parameters
$boolean | ||
$triggerDeprecationError |
Return Value
$this |
bool isSynchronized($triggerDeprecationError = true) deprecated
deprecated
Whether this service is synchronized.
Parameters
$triggerDeprecationError |
Return Value
bool |
$this setLazy($boolean)
Sets the lazy flag of this service.
Parameters
$boolean |
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 |
Definition setDeprecated($boolean = true, string $template = null)
Whether this definition is deprecated, that means it should not be called anymore.
Parameters
$boolean | ||
string | $template | Template message to use if the definition is deprecated |
Return Value
Definition | the current instance |
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(callable $callable)
Sets a configurator to call after the service is fully initialized.
Parameters
callable | $callable | 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 |
Definition setAutowiringTypes(array $types)
Sets types that will default to this definition.
Parameters
array | $types |
Return Value
Definition | The current instance |
bool isAutowired()
Is the definition autowired?
Return Value
bool |
Definition setAutowired(bool $autowired)
Sets autowired.
Parameters
bool | $autowired |
Return Value
Definition | The current instance |
string[] getAutowiringTypes()
Gets autowiring types that will default to this definition.
Return Value
string[] |
Definition addAutowiringType(string $type)
Adds a type that will default to this definition.
Parameters
string | $type |
Return Value
Definition | The current instance |
Definition removeAutowiringType(string $type)
Removes a type.
Parameters
string | $type |
Return Value
Definition | The current instance |
bool hasAutowiringType(string $type)
Will this definition default for the given type?
Parameters
string | $type |
Return Value
bool |
string getParent()
Returns the Definition being decorated.
Return Value
string |
array getChanges()
Returns all changes tracked for the Definition object.
Return Value
array | An array of changes for this Definition |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/DependencyInjection/DefinitionDecorator.html