summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-07-13 13:28:14 (GMT)
committerNathaniel Catchpole2018-07-13 13:28:14 (GMT)
commit62e59a00f2c0c4f1577b307eb9f80b703060e981 (patch)
tree931a708a5167fd900ab7b2d7a309d0b0017e6235
parent5e4ce076324abfbb783f00b6158b04a922b64ed5 (diff)
Issue #2981025 by msankhala, barthje, Stockticker, penyaskito, alexpott: Replace injection of deprecated entity.manager service with entity_type.manager in \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter and LanguageFormatter
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php12
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php23
2 files changed, 21 insertions, 14 deletions
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php
index 43c4c98..6f3c7ca 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php
@@ -2,7 +2,7 @@
namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
-use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Form\FormStateInterface;
@@ -47,13 +47,13 @@ class LanguageFormatter extends StringFormatter {
* The view mode.
* @param array $third_party_settings
* Any third party settings settings.
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager.
+ * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+ * The entity type manager.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
*/
- public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
- parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $entity_manager);
+ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager) {
+ parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $entity_type_manager);
$this->languageManager = $language_manager;
}
@@ -70,7 +70,7 @@ class LanguageFormatter extends StringFormatter {
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings'],
- $container->get('entity.manager'),
+ $container->get('entity_type.manager'),
$container->get('language_manager')
);
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
index 08642a0..320005c 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
@@ -3,7 +3,7 @@
namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FormatterBase;
@@ -30,6 +30,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class StringFormatter extends FormatterBase implements ContainerFactoryPluginInterface {
/**
+ * The entity type manager.
+ *
+ * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+ */
+ protected $entityTypeManager;
+
+ /**
* Constructs a StringFormatter instance.
*
* @param string $plugin_id
@@ -46,13 +53,13 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
* The view mode.
* @param array $third_party_settings
* Any third party settings settings.
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager.
+ * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+ * The entity type manager.
*/
- public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityManagerInterface $entity_manager) {
+ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
- $this->entityManager = $entity_manager;
+ $this->entityTypeManager = $entity_type_manager;
}
/**
@@ -67,7 +74,7 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings'],
- $container->get('entity.manager')
+ $container->get('entity_type.manager')
);
}
@@ -87,7 +94,7 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
- $entity_type = $this->entityManager->getDefinition($this->fieldDefinition->getTargetEntityTypeId());
+ $entity_type = $this->entityTypeManager->getDefinition($this->fieldDefinition->getTargetEntityTypeId());
$form['link_to_entity'] = [
'#type' => 'checkbox',
@@ -104,7 +111,7 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
public function settingsSummary() {
$summary = [];
if ($this->getSetting('link_to_entity')) {
- $entity_type = $this->entityManager->getDefinition($this->fieldDefinition->getTargetEntityTypeId());
+ $entity_type = $this->entityTypeManager->getDefinition($this->fieldDefinition->getTargetEntityTypeId());
$summary[] = $this->t('Linked to the @entity_label', ['@entity_label' => $entity_type->getLabel()]);
}
return $summary;