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;
*/
class StringFormatter extends FormatterBase implements ContainerFactoryPluginInterface {
+ /**
+ * The entity type manager.
+ *
+ * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+ */
+ protected $entityTypeManager;
+
/**
* Constructs a StringFormatter instance.
*
* 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;
}
/**
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings'],
- $container->get('entity.manager')
+ $container->get('entity_type.manager')
);
}
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',
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;