Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Definition.php

function Definition::setDecoratedService

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:

Return value

$this

Throws

InvalidArgumentException in case the decorated service id and the new decorated service id are equals

File

vendor/symfony/dependency-injection/Definition.php, line 136

Class

Definition
Definition represents a service definition.

Namespace

Symfony\Component\DependencyInjection

Code

public function setDecoratedService(?string $id, ?string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) : static {
    if ($renamedId && $id === $renamedId) {
        throw new InvalidArgumentException(\sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
    }
    $this->changes['decorated_service'] = true;
    if (null === $id) {
        $this->decoratedService = null;
    }
    else {
        $this->decoratedService = [
            $id,
            $renamedId,
            $priority,
        ];
        if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
            $this->decoratedService[] = $invalidBehavior;
        }
    }
    return $this;
}
RSS feed
Powered by Drupal