annotate core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@18 1 <?php
Chris@18 2
Chris@18 3 namespace Drupal\Core\DependencyInjection;
Chris@18 4
Chris@18 5 /**
Chris@18 6 * Provides a standard way to announce deprecated properties.
Chris@18 7 */
Chris@18 8 trait DeprecatedServicePropertyTrait {
Chris@18 9
Chris@18 10 /**
Chris@18 11 * Alows to access deprecated/removed properties.
Chris@18 12 *
Chris@18 13 * This method must be public.
Chris@18 14 */
Chris@18 15 public function __get($name) {
Chris@18 16 if (!isset($this->deprecatedProperties)) {
Chris@18 17 throw new \LogicException('The deprecatedProperties property must be defined to use this trait.');
Chris@18 18 }
Chris@18 19
Chris@18 20 if (isset($this->deprecatedProperties[$name])) {
Chris@18 21 $service_name = $this->deprecatedProperties[$name];
Chris@18 22 $class_name = static::class;
Chris@18 23 @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);
Chris@18 24 return \Drupal::service($service_name);
Chris@18 25 }
Chris@18 26 }
Chris@18 27
Chris@18 28 }