Use $this->entityTypeManager() instead of Drupal::entityTypeManager() in entity classes #796
This commit is contained in:
parent
6abe3e73b0
commit
fb6fd0d0bc
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue