From fb6fd0d0bc265fd7098df5fd21d620720a09f40c Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Fri, 2 Feb 2024 12:29:08 -0500 Subject: [PATCH] Use $this->entityTypeManager() instead of Drupal::entityTypeManager() in entity classes #796 --- modules/core/asset/src/Entity/Asset.php | 2 +- modules/core/asset/src/Entity/AssetType.php | 4 ++-- modules/core/data_stream/src/Entity/DataStream.php | 2 +- modules/core/plan/src/Entity/Plan.php | 2 +- modules/core/plan/src/Entity/PlanRecord.php | 2 +- modules/core/plan/src/Entity/PlanType.php | 4 ++-- modules/core/quantity/src/Entity/Quantity.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/core/asset/src/Entity/Asset.php b/modules/core/asset/src/Entity/Asset.php index 1095e2e8c..e75a69188 100644 --- a/modules/core/asset/src/Entity/Asset.php +++ b/modules/core/asset/src/Entity/Asset.php @@ -148,7 +148,7 @@ class Asset extends RevisionableContentEntityBase implements AssetInterface { */ public function getBundleLabel() { /** @var \Drupal\asset\Entity\AssetTypeInterface $type */ - $type = \Drupal::entityTypeManager() + $type = $this->entityTypeManager() ->getStorage('asset_type') ->load($this->bundle()); return $type->label(); diff --git a/modules/core/asset/src/Entity/AssetType.php b/modules/core/asset/src/Entity/AssetType.php index 8f11134ff..659204f73 100644 --- a/modules/core/asset/src/Entity/AssetType.php +++ b/modules/core/asset/src/Entity/AssetType.php @@ -113,7 +113,7 @@ class AssetType extends ConfigEntityBundleBase implements AssetTypeInterface { // If the asset type id changed, update all existing assets of that type. if ($update && $this->getOriginalId() != $this->id()) { - $update_count = \Drupal::entityTypeManager()->getStorage('asset')->updateType($this->getOriginalId(), $this->id()); + $update_count = $this->entityTypeManager()->getStorage('asset')->updateType($this->getOriginalId(), $this->id()); if ($update_count) { \Drupal::messenger()->addMessage(\Drupal::translation()->formatPlural($update_count, 'Changed the asset type of 1 post from %old-type to %type.', @@ -127,7 +127,7 @@ class AssetType extends ConfigEntityBundleBase implements AssetTypeInterface { if ($update) { // Clear the cached field definitions as some settings affect the field // definitions. - \Drupal::entityTypeManager()->clearCachedDefinitions(); + $this->entityTypeManager()->clearCachedDefinitions(); \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); } } diff --git a/modules/core/data_stream/src/Entity/DataStream.php b/modules/core/data_stream/src/Entity/DataStream.php index 82a21bd30..b395b9e1e 100644 --- a/modules/core/data_stream/src/Entity/DataStream.php +++ b/modules/core/data_stream/src/Entity/DataStream.php @@ -134,7 +134,7 @@ class DataStream extends ContentEntityBase implements DataStreamInterface { */ public function getBundleLabel() { /** @var \Drupal\data_stream\Entity\DataStreamTypeInterface $type */ - $type = \Drupal::entityTypeManager() + $type = $this->entityTypeManager() ->getStorage('data_stream_type') ->load($this->bundle()); return $type->label(); diff --git a/modules/core/plan/src/Entity/Plan.php b/modules/core/plan/src/Entity/Plan.php index 61b020777..93983a927 100644 --- a/modules/core/plan/src/Entity/Plan.php +++ b/modules/core/plan/src/Entity/Plan.php @@ -148,7 +148,7 @@ class Plan extends RevisionableContentEntityBase implements PlanInterface { */ public function getBundleLabel() { /** @var \Drupal\plan\Entity\PlanTypeInterface $type */ - $type = \Drupal::entityTypeManager() + $type = $this->entityTypeManager() ->getStorage('plan_type') ->load($this->bundle()); return $type->label(); diff --git a/modules/core/plan/src/Entity/PlanRecord.php b/modules/core/plan/src/Entity/PlanRecord.php index 1993863e9..aa5e26b75 100644 --- a/modules/core/plan/src/Entity/PlanRecord.php +++ b/modules/core/plan/src/Entity/PlanRecord.php @@ -54,7 +54,7 @@ class PlanRecord extends ContentEntityBase implements PlanRecordInterface { */ public function getBundleLabel() { /** @var \Drupal\plan\Entity\PlanRecordTypeInterface $type */ - $type = \Drupal::entityTypeManager() + $type = $this->entityTypeManager() ->getStorage('plan_record_type') ->load($this->bundle()); return $type->label(); diff --git a/modules/core/plan/src/Entity/PlanType.php b/modules/core/plan/src/Entity/PlanType.php index 3084fe98e..e4270124f 100644 --- a/modules/core/plan/src/Entity/PlanType.php +++ b/modules/core/plan/src/Entity/PlanType.php @@ -113,7 +113,7 @@ class PlanType extends ConfigEntityBundleBase implements PlanTypeInterface { // If the plan type id changed, update all existing plans of that type. if ($update && $this->getOriginalId() != $this->id()) { - $update_count = \Drupal::entityTypeManager()->getStorage('plan')->updateType($this->getOriginalId(), $this->id()); + $update_count = $this->entityTypeManager()->getStorage('plan')->updateType($this->getOriginalId(), $this->id()); if ($update_count) { \Drupal::messenger()->addMessage(\Drupal::translation()->formatPlural($update_count, 'Changed the plan type of 1 post from %old-type to %type.', @@ -127,7 +127,7 @@ class PlanType extends ConfigEntityBundleBase implements PlanTypeInterface { if ($update) { // Clear the cached field definitions as some settings affect the field // definitions. - \Drupal::entityTypeManager()->clearCachedDefinitions(); + $this->entityTypeManager()->clearCachedDefinitions(); \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); } } diff --git a/modules/core/quantity/src/Entity/Quantity.php b/modules/core/quantity/src/Entity/Quantity.php index abcc642dd..85ecf7711 100644 --- a/modules/core/quantity/src/Entity/Quantity.php +++ b/modules/core/quantity/src/Entity/Quantity.php @@ -118,7 +118,7 @@ class Quantity extends RevisionableContentEntityBase implements QuantityInterfac */ public function getBundleLabel() { /** @var \Drupal\quantity\Entity\QuantityTypeInterface $type */ - $type = \Drupal::entityTypeManager() + $type = $this->entityTypeManager() ->getStorage('quantity_type') ->load($this->bundle()); return $type->label();