trait DeprecatedServicePropertyTrait

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait
  2. 10 core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait
  3. 11.x core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait

Provides a standard way to announce deprecated properties.

Hierarchy

4 files declare their use of DeprecatedServicePropertyTrait
BookNavigationCacheContext.php in core/modules/book/src/Cache/BookNavigationCacheContext.php
ProviderRepository.php in core/modules/media/src/OEmbed/ProviderRepository.php
SiteConfigureForm.php in core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
Vid.php in core/modules/node/src/Plugin/views/argument/Vid.php

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 10.0.0.", E_USER_DEPRECATED);
            return \Drupal::service($service_name);
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.