Mercurial > hg > cmmr2012-drupal-site
comparison core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Core\DependencyInjection; | |
4 | |
5 /** | |
6 * Provides a standard way to announce deprecated properties. | |
7 */ | |
8 trait DeprecatedServicePropertyTrait { | |
9 | |
10 /** | |
11 * Alows to access deprecated/removed properties. | |
12 * | |
13 * This method must be public. | |
14 */ | |
15 public function __get($name) { | |
16 if (!isset($this->deprecatedProperties)) { | |
17 throw new \LogicException('The deprecatedProperties property must be defined to use this trait.'); | |
18 } | |
19 | |
20 if (isset($this->deprecatedProperties[$name])) { | |
21 $service_name = $this->deprecatedProperties[$name]; | |
22 $class_name = static::class; | |
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); | |
24 return \Drupal::service($service_name); | |
25 } | |
26 } | |
27 | |
28 } |