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

Breadcrumb

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

trait DeprecatedServicePropertyTrait

Provides a standard way to announce deprecated properties.

Hierarchy

  • trait \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait
3 files declare their use of DeprecatedServicePropertyTrait
FileSystem.php in core/lib/Drupal/Core/File/FileSystem.php
Permission.php in core/modules/user/src/Plugin/views/access/Permission.php
Permissions.php in core/modules/user/src/Plugin/views/filter/Permissions.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(string $name) : mixed {
        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;
            // phpcs:ignore Drupal.Semantics.FunctionTriggerError
            @trigger_error("The property {$name} ({$service_name} service) is deprecated in {$class_name} and will be removed before Drupal 11.0.0.", E_USER_DEPRECATED);
            return \Drupal::service($service_name);
        }
        return NULL;
    }

}

Members

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal