You are here

trait DeprecatedServicePropertyTrait in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait

Provides a standard way to announce deprecated properties.

Hierarchy

106 files declare their use of DeprecatedServicePropertyTrait
AdminNegotiator.php in core/modules/user/src/Theme/AdminNegotiator.php
AliasManager.php in core/lib/Drupal/Core/Path/AliasManager.php
AliasWhitelist.php in core/lib/Drupal/Core/Path/AliasWhitelist.php
BasicAuth.php in core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
Block.php in core/modules/views/src/Plugin/views/display/Block.php

... See full list

File

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

Namespace

Drupal\Core\DependencyInjection
View source
trait DeprecatedServicePropertyTrait {

  /**
   * Allows to access deprecated/removed properties.
   *
   * This method must be public.
   */
  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 9.0.0.", E_USER_DEPRECATED);
      return \Drupal::service($service_name);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.