W3cubDocs

/Symfony 2.7

Symfony\Component\DependencyInjection\Definition

class Definition

Definition represents a service definition.

Methods

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

Constructor.

Definition setFactory(string|array $factory)

Sets a factory.

string|array getFactory()

Gets the factory.

Definition setFactoryClass(string $factoryClass)

Sets the name of the class that acts as a factory using the factory method, which will be invoked statically.

string|null getFactoryClass()

Gets the factory class.

Definition setFactoryMethod(string $factoryMethod)

Sets the factory method able to create an instance of this class.

Definition setDecoratedService(null|string $id, null|string $renamedId = null)

Sets the service that this service is decorating.

null|array getDecoratedService()

Gets the service that decorates this service.

string|null getFactoryMethod()

Gets the factory method.

Definition setFactoryService(string $factoryService)

Sets the name of the service that acts as a factory using the factory method.

string|null getFactoryService()

Gets the factory service id.

Definition setClass(string $class)

Sets the service class.

string|null getClass()

Gets the service class.

Definition setArguments(array $arguments)

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

setProperties(array $properties)
getProperties()
setProperty($name, $value)
Definition addArgument(mixed $argument)

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

Definition replaceArgument(int $index, mixed $argument)

Sets a specific argument

array getArguments()

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

mixed getArgument(int $index)

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

Definition setMethodCalls(array $calls = array())

Sets the methods to call after service initialization.

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

Adds a method to call after service initialization.

Definition 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.

Definition setTags(array $tags)

Sets tags for this definition

array getTags()

Returns all tags.

array getTag(string $name)

Gets a tag by name.

Definition 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

Definition clearTag(string $name)

Clears all tags for a given name.

Definition clearTags()

Clears the tags for this definition.

Definition setFile(string $file)

Sets a file to require before creating the service.

string|null getFile()

Gets the file to require before creating the service.

Definition setScope(string $scope)

Sets the scope of the service

string getScope()

Returns the scope of the service

Definition setPublic(bool $boolean)

Sets the visibility of this service.

bool isPublic()

Whether this service is public facing

Definition setSynchronized(bool $boolean)

Sets the synchronized flag of this service.

bool isSynchronized()

Whether this service is synchronized.

Definition setLazy(bool $lazy)

Sets the lazy flag of this service.

bool isLazy()

Whether this service is lazy.

Definition 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.

Definition 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.

Definition 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.

Details

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

Constructor.

Parameters

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

public Definition 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

Definition The current instance

public 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

public Definition setFactoryClass(string $factoryClass)

Sets the name of the class that acts as a factory using the factory method, which will be invoked statically.

Parameters

string $factoryClass The factory class name

Return Value

Definition The current instance

public string|null getFactoryClass()

Gets the factory class.

Return Value

string|null The factory class name

public Definition setFactoryMethod(string $factoryMethod)

Sets the factory method able to create an instance of this class.

Parameters

string $factoryMethod The factory method name

Return Value

Definition The current instance

public Definition setDecoratedService(null|string $id, null|string $renamedId = null)

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

Return Value

Definition The current instance

Exceptions

InvalidArgumentException In case the decorated service id and the new decorated service id are equals.

public null|array getDecoratedService()

Gets the service that decorates this service.

Return Value

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

public string|null getFactoryMethod()

Gets the factory method.

Return Value

string|null The factory method name

public Definition setFactoryService(string $factoryService)

Sets the name of the service that acts as a factory using the factory method.

Parameters

string $factoryService The factory service id

Return Value

Definition The current instance

public string|null getFactoryService()

Gets the factory service id.

Return Value

string|null The factory service id

public Definition setClass(string $class)

Sets the service class.

Parameters

string $class The service class

Return Value

Definition The current instance

public string|null getClass()

Gets the service class.

Return Value

string|null The service class

public Definition setArguments(array $arguments)

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

Parameters

array $arguments An array of arguments

Return Value

Definition The current instance

public setProperties(array $properties)

Parameters

array $properties

public getProperties()

public setProperty($name, $value)

Parameters

$name
$value

public Definition addArgument(mixed $argument)

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

Parameters

mixed $argument An argument

Return Value

Definition The current instance

public Definition replaceArgument(int $index, mixed $argument)

Sets a specific argument

Parameters

int $index
mixed $argument

Return Value

Definition The current instance

Exceptions

OutOfBoundsException When the replaced argument does not exist

public array getArguments()

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

Return Value

array The array of arguments

public mixed getArgument(int $index)

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

Parameters

int $index

Return Value

mixed The argument value

Exceptions

OutOfBoundsException When the argument does not exist

public Definition setMethodCalls(array $calls = array())

Sets the methods to call after service initialization.

Parameters

array $calls An array of method calls

Return Value

Definition The current instance

public Definition 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

Definition The current instance

Exceptions

InvalidArgumentException on empty $method param

public Definition removeMethodCall(string $method)

Removes a method to call after service initialization.

Parameters

string $method The method name to remove

Return Value

Definition The current instance

public 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

public array getMethodCalls()

Gets the methods to call after service initialization.

Return Value

array An array of method calls

public Definition setTags(array $tags)

Sets tags for this definition

Parameters

array $tags

Return Value

Definition the current instance

public array getTags()

Returns all tags.

Return Value

array An array of tags

public array getTag(string $name)

Gets a tag by name.

Parameters

string $name The tag name

Return Value

array An array of attributes

public Definition 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

Definition The current instance

public bool hasTag(string $name)

Whether this definition has a tag with the given name

Parameters

string $name

Return Value

bool

public Definition clearTag(string $name)

Clears all tags for a given name.

Parameters

string $name The tag name

Return Value

Definition

public Definition clearTags()

Clears the tags for this definition.

Return Value

Definition The current instance

public Definition setFile(string $file)

Sets a file to require before creating the service.

Parameters

string $file A full pathname to include

Return Value

Definition The current instance

public string|null getFile()

Gets the file to require before creating the service.

Return Value

string|null The full pathname to include

public Definition setScope(string $scope)

Sets the scope of the service

Parameters

string $scope Whether the service must be shared or not

Return Value

Definition The current instance

public string getScope()

Returns the scope of the service

Return Value

string

public Definition setPublic(bool $boolean)

Sets the visibility of this service.

Parameters

bool $boolean

Return Value

Definition The current instance

public bool isPublic()

Whether this service is public facing

Return Value

bool

public Definition setSynchronized(bool $boolean)

Sets the synchronized flag of this service.

Parameters

bool $boolean

Return Value

Definition The current instance

public bool isSynchronized()

Whether this service is synchronized.

Return Value

bool

public Definition setLazy(bool $lazy)

Sets the lazy flag of this service.

Parameters

bool $lazy

Return Value

Definition The current instance

public bool isLazy()

Whether this service is lazy.

Return Value

bool

public Definition setSynthetic(bool $boolean)

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

Parameters

bool $boolean

Return Value

Definition the current instance

public bool isSynthetic()

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

Return Value

bool

public Definition setAbstract(bool $boolean)

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

Parameters

bool $boolean

Return Value

Definition the current instance

public bool isAbstract()

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

Return Value

bool

public Definition setConfigurator(callable $callable)

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

Parameters

callable $callable A PHP callable

Return Value

Definition The current instance

public callable|null getConfigurator()

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

Return Value

callable|null The PHP callable to call

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Component/DependencyInjection/Definition.html