Copied!

Definition represents a service definition.

CloneableInstantiable
Properties
public ?int $decorationOnInvalid = NULL
 
  • internal Used to store the behavior to follow when using service decoration and the decorated service is invalid
public ?string $innerServiceId = NULL
 
  • internal Used to store the name of the inner id when using service decoration together with autowiring
Methods
public __construct(?string $class = NULL, array $arguments = [])
public addArgument(?mixed $argument) : static
 

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

  • return $this
public addError(Closure|self|string $error) : static
 

Add an error that occurred when building this Definition.

  • return $this
public addMethodCall(string $method, array $arguments = [], bool $returnsClone = false) : static
 

Adds a method to call after service initialization.

  • param string $method The method name to call
  • param array $arguments An array of arguments to pass to the method call
  • param bool $returnsClone Whether the call returns the service instance or not
  • return $this
  • throws \InvalidArgumentException on empty $method param
public addTag(string $name, array $attributes = []) : static
 

Adds a tag for this definition.

  • return $this
public clearTag(string $name) : static
 

Clears all tags for a given name.

  • return $this
public clearTags() : static
 

Clears the tags for this definition.

  • return $this
public getArgument(string|int $index) : ?mixed
 

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

  • throws \OutOfBoundsException When the argument does not exist
public getArguments() : array
 

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

public getBindings() : array
 

Gets bindings.

  • return \BoundArgument[]
public getChanges() : array
 

Returns all changes tracked for the Definition object.

public getClass() : ?string
 

Gets the service class.

  • return class-string|null
public getConfigurator() : array|string|?null
 

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

public getDecoratedService() : ?array
 

Gets the service that this service is decorating.

  • return 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
public getDeprecation(string $id) : array
 
  • param string $id Service id relying on this definition
public getErrors() : array
 

Returns any errors that occurred while building this Definition.

public getFactory() : array|string|?null
 

Gets the factory.

  • return string|array|null The PHP function or an array containing a class/Reference and a method to call
public getFile() : ?string
 

Gets the file to require before creating the service.

public getInstanceofConditionals() : array
 

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

  • return \ChildDefinition[]
public getMethodCalls() : array
 

Gets the methods to call after service initialization.

public getProperties() : array
 

Gets the properties to define when creating the service.

public getTag(string $name) : array
 

Gets a tag by name.

public getTags() : array
 

Returns all tags.

public hasErrors() : bool
public hasMethodCall(string $method) : bool
 

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

public hasTag(string $name) : bool
 

Whether this definition has a tag with the given name.

public isAbstract() : bool
 

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

public isAutoconfigured() : bool
public isAutowired() : bool
 

Is the definition autowired?

public isDeprecated() : bool
 

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

public isLazy() : bool
 

Whether this service is lazy.

public isPrivate() : bool
 

Whether this service is private.

public isPublic() : bool
 

Whether this service is public facing.

public isShared() : bool
 

Whether this service is shared.

public isSynthetic() : bool
 

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

public removeMethodCall(string $method) : static
 

Removes a method to call after service initialization.

  • return $this
public replaceArgument(string|int $index, ?mixed $argument) : static
 

Replaces a specific argument.

  • return $this
  • throws \OutOfBoundsException When the replaced argument does not exist
public setAbstract(bool $boolean) : static
 

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

  • return $this
public setArgument(string|int $key, ?mixed $value) : static
 

Sets a specific argument.

  • return $this
public setArguments(array $arguments) : static
 

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

  • return $this
public setAutoconfigured(bool $autoconfigured) : static
 

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

  • return $this
public setAutowired(bool $autowired) : static
 

Enables/disables autowiring.

  • return $this
public setBindings(array $bindings) : static
 

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

  • return $this
public setChanges(array $changes) : static
 

Sets the tracked changes for the Definition object.

  • param array $changes An array of changes for this Definition
  • return $this
public setClass(?string $class) : static
 

Sets the service class.

  • return $this
public setConfigurator(Symfony\Component\DependencyInjection\Reference|array|string|?null $configurator) : static
 

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

  • param string|array|\Reference|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call
  • return $this
public setDecoratedService(?string $id, ?string $renamedId = NULL, int $priority = 0, int $invalidBehavior = 1Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) : static
 

Sets the service that this service is decorating.

  • param string|null $id The decorated service id, use null to remove decoration
  • param string|null $renamedId The new decorated service id
  • return $this
  • throws \InvalidArgumentException in case the decorated service id and the new decorated service id are equals
public setDeprecated(string $package, string $version, string $message) : static
 

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

  • param string $package The name of the composer package that is triggering the deprecation
  • param string $version The version of the package that introduced the deprecation
  • param string $message The deprecation message to use
  • return $this
  • throws \InvalidArgumentException when the message template is invalid
public setFactory(Symfony\Component\DependencyInjection\Reference|array|string|?null $factory) : static
 

Sets a factory.

  • param string|array|\Reference|null $factory A PHP function, reference or an array containing a class/Reference and a method to call
  • return $this
public setFile(?string $file) : static
 

Sets a file to require before creating the service.

  • return $this
public setInstanceofConditionals(array $instanceof) : static
 

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

  • param \ChildDefinition[] $instanceof
  • return $this
public setLazy(bool $lazy) : static
 

Sets the lazy flag of this service.

  • return $this
public setMethodCalls(array $calls = []) : static
 

Sets the methods to call after service initialization.

  • return $this
public setProperties(array $properties) : static
 

Sets the properties to define when creating the service.

  • return $this
public setProperty(string $name, ?mixed $value) : static
 

Sets a specific property.

  • return $this
public setPublic(bool $boolean) : static
 

Sets the visibility of this service.

  • return $this
public setShared(bool $shared) : static
 

Sets if the service must be shared or not.

  • return $this
public setSynthetic(bool $boolean) : static
 

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

  • return $this
public setTags(array $tags) : static
 

Sets tags for this definition.

  • return $this
Properties
protected array $arguments = []
Constants
private Symfony\Component\DependencyInjection\Definition::DEFAULT_DEPRECATION_TEMPLATE = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
Properties
private bool $abstract = false
private bool $autoconfigured = false
private bool $autowired = false
private array $bindings = []
private array $calls = []
private array $changes = []
private ?string $class = NULL
private array|string|?null $configurator = NULL
private ?array $decoratedService = NULL
private array $deprecation = []
private array $errors = []
private array|string|?null $factory = NULL
private ?string $file = NULL
private array $instanceof = []
private bool $lazy = false
private array $properties = []
private bool $public = false
private bool $shared = true
private bool $synthetic = false
private array $tags = []
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration