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

Breadcrumb

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

function Definition::setDeprecated

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

Parameters

string $package The name of the composer package that is triggering the deprecation:

string $version The version of the package that introduced the deprecation:

string $message The deprecation message to use:

Return value

$this

Throws

InvalidArgumentException when the message template is invalid

File

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

Class

Definition
Definition represents a service definition.

Namespace

Symfony\Component\DependencyInjection

Code

public function setDeprecated(string $package, string $version, string $message) : static {
    if ('' !== $message) {
        if (preg_match('#[\\r\\n]|\\*/#', $message)) {
            throw new InvalidArgumentException('Invalid characters found in deprecation template.');
        }
        if (!str_contains($message, '%service_id%')) {
            throw new InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.');
        }
    }
    $this->changes['deprecated'] = true;
    $this->deprecation = [
        'package' => $package,
        'version' => $version,
        'message' => $message ?: self::DEFAULT_DEPRECATION_TEMPLATE,
    ];
    return $this;
}
RSS feed
Powered by Drupal