You are here

public function DeprecatedServicePropertyTrait::__get in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait::__get()
  2. 9 core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait::__get()

Allows to access deprecated/removed properties.

This method must be public.

File

core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php, line 15

Class

DeprecatedServicePropertyTrait
Provides a standard way to announce deprecated properties.

Namespace

Drupal\Core\DependencyInjection

Code

public function __get($name) {
  if (!isset($this->deprecatedProperties)) {
    throw new \LogicException('The deprecatedProperties property must be defined to use this trait.');
  }
  if (isset($this->deprecatedProperties[$name])) {
    $service_name = $this->deprecatedProperties[$name];
    $class_name = static::class;
    @trigger_error("The property {$name} ({$service_name} service) is deprecated in {$class_name} and will be removed before Drupal 10.0.0.", E_USER_DEPRECATED);
    return \Drupal::service($service_name);
  }
}