W3cubDocs

/Symfony 4.1

ServiceConfigurator

class ServiceConfigurator extends AbstractServiceConfigurator

Traits

AbstractTrait
ArgumentTrait
AutoconfigureTrait
AutowireTrait
BindTrait
CallTrait
ClassTrait
ConfiguratorTrait
DecorateTrait
DeprecateTrait
FactoryTrait
FileTrait
LazyTrait
ParentTrait
PropertyTrait
PublicTrait
ShareTrait
SyntheticTrait
TagTrait

Constants

FACTORY

Properties

protected $definition from AbstractConfigurator
protected $parent from AbstractServiceConfigurator
protected $id from AbstractServiceConfigurator

Methods

__call($method, $args) from AbstractConfigurator
static mixed processValue(mixed $value, bool $allowServices = false)

Checks that a value is valid, optionally replacing Definition and Reference configurators by their configure value.

from AbstractConfigurator
__construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, string $id, array $defaultTags)
__destruct()
ServiceConfigurator set(string $id, string $class = null)

Registers a service.

from AbstractServiceConfigurator
AliasConfigurator alias(string $id, string $referencedId)

Creates an alias.

from AbstractServiceConfigurator
PrototypeConfigurator load(string $namespace, string $resource)

Registers a PSR-4 namespace using a glob pattern.

from AbstractServiceConfigurator
ServiceConfigurator get(string $id)

Gets an already defined service definition.

from AbstractServiceConfigurator
ServiceConfigurator __invoke(string $id, string $class = null)

Registers a service.

from AbstractServiceConfigurator
$this abstract(bool $abstract = true)

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

from AbstractTrait
$this args(array $arguments)

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

from ArgumentTrait
$this arg(string|int $key, mixed $value)

Sets one argument to pass to the service constructor/factory method.

from ArgumentTrait
$this autoconfigure(bool $autoconfigured = true)

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

from AutoconfigureTrait
$this autowire(bool $autowired = true)

Enables/disables autowiring.

from AutowireTrait
$this bind(string $nameOrFqcn, mixed $valueOrRef)

Sets bindings.

from BindTrait
$this call(string $method, array $arguments = array())

Adds a method to call after service initialization.

from CallTrait
$this class($class)

Sets the service class.

from ClassTrait
$this configurator(string|array $configurator)

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

from ConfiguratorTrait
$this decorate(string|null $id, string|null $renamedId = null, int $priority = 0)

Sets the service that this service is decorating.

from DecorateTrait
$this deprecate(string $template = null)

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

from DeprecateTrait
$this factory(string|array $factory)

Sets a factory.

from FactoryTrait
$this file(string $file)

Sets a file to require before creating the service.

from FileTrait
$this lazy(bool $lazy = true)

Sets the lazy flag of this service.

from LazyTrait
$this parent(string $parent)

Sets the Definition to inherit from.

from ParentTrait
$this property(string $name, $value)

Sets a specific property.

from PropertyTrait
$this public() from PublicTrait
$this private() from PublicTrait
$this share(bool $shared = true)

Sets if the service must be shared or not.

from ShareTrait
$this synthetic(bool $synthetic = true)

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

from SyntheticTrait
$this tag(string $name, array $attributes = array())

Adds a tag for this definition.

from TagTrait

Details

__call($method, $args)

Parameters

$method
$args

static mixed processValue(mixed $value, bool $allowServices = false)

Checks that a value is valid, optionally replacing Definition and Reference configurators by their configure value.

Parameters

mixed $value
bool $allowServices whether Definition and Reference are allowed; by default, only scalars and arrays are

Return Value

mixed the value, optionally cast to a Definition/Reference

__construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, string $id, array $defaultTags)

Parameters

ContainerBuilder $container
array $instanceof
bool $allowParent
ServicesConfigurator $parent
Definition $definition
string $id
array $defaultTags

__destruct()

final ServiceConfigurator set(string $id, string $class = null)

Registers a service.

Parameters

string $id
string $class

Return Value

ServiceConfigurator

final AliasConfigurator alias(string $id, string $referencedId)

Creates an alias.

Parameters

string $id
string $referencedId

Return Value

AliasConfigurator

final PrototypeConfigurator load(string $namespace, string $resource)

Registers a PSR-4 namespace using a glob pattern.

Parameters

string $namespace
string $resource

Return Value

PrototypeConfigurator

final ServiceConfigurator get(string $id)

Gets an already defined service definition.

Parameters

string $id

Return Value

ServiceConfigurator

Exceptions

ServiceNotFoundException if the service definition does not exist

final ServiceConfigurator __invoke(string $id, string $class = null)

Registers a service.

Parameters

string $id
string $class

Return Value

ServiceConfigurator

final $this abstract(bool $abstract = true)

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

Parameters

bool $abstract

Return Value

$this

final $this args(array $arguments)

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

Parameters

array $arguments An array of arguments

Return Value

$this

final $this arg(string|int $key, mixed $value)

Sets one argument to pass to the service constructor/factory method.

Parameters

string|int $key
mixed $value

Return Value

$this

final $this autoconfigure(bool $autoconfigured = true)

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

Parameters

bool $autoconfigured

Return Value

$this

Exceptions

InvalidArgumentException when a parent is already set

final $this autowire(bool $autowired = true)

Enables/disables autowiring.

Parameters

bool $autowired

Return Value

$this

final $this bind(string $nameOrFqcn, mixed $valueOrRef)

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

string $nameOrFqcn A parameter name with its "$" prefix, or a FQCN
mixed $valueOrRef The value or reference to bind

Return Value

$this

final $this call(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

final $this class($class)

Sets the service class.

Parameters

$class

Return Value

$this

final $this configurator(string|array $configurator)

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

Parameters

string|array $configurator A PHP callable reference

Return Value

$this

final $this decorate(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

final $this deprecate(string $template = null)

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

Parameters

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

Return Value

$this

Exceptions

InvalidArgumentException when the message template is invalid

final $this factory(string|array $factory)

Sets a factory.

Parameters

string|array $factory A PHP callable reference

Return Value

$this

final $this file(string $file)

Sets a file to require before creating the service.

Parameters

string $file A full pathname to include

Return Value

$this

final $this lazy(bool $lazy = true)

Sets the lazy flag of this service.

Parameters

bool $lazy

Return Value

$this

final $this parent(string $parent)

Sets the Definition to inherit from.

Parameters

string $parent

Return Value

$this

Exceptions

InvalidArgumentException when parent cannot be set

final $this property(string $name, $value)

Sets a specific property.

Parameters

string $name
$value

Return Value

$this

final $this public()

Return Value

$this

final $this private()

Return Value

$this

final $this share(bool $shared = true)

Sets if the service must be shared or not.

Parameters

bool $shared Whether the service must be shared or not

Return Value

$this

final $this synthetic(bool $synthetic = true)

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

Parameters

bool $synthetic

Return Value

$this

final $this tag(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