Commit 9d96532b authored by catch's avatar catch

Issue #3035383 by andypost, martin107, Berdir: Replace deprecated usages of...

Issue #3035383 by andypost, martin107, Berdir: Replace deprecated usages of entityManager in list builder classes
parent d297e234
......@@ -54,7 +54,7 @@ class EntityListBuilder extends EntityHandlerBase implements EntityListBuilderIn
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id())
$container->get('entity_type.manager')->getStorage($entity_type->id())
);
}
......
......@@ -51,7 +51,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('plugin.manager.action')
);
}
......
......@@ -90,7 +90,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('theme.manager'),
$container->get('form_builder'),
$container->get('messenger')
......
......@@ -34,7 +34,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('theme_handler')
);
}
......
......@@ -54,12 +54,13 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
$entity_type_manager = $container->get('entity_type.manager');
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$entity_type_manager->getStorage($entity_type->id()),
$container->get('date.formatter'),
$container->get('redirect.destination'),
$container->get('entity_type.manager')
$entity_type_manager
);
}
......
......@@ -45,11 +45,11 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
$entity_manager = $container->get('entity.manager');
$entity_type_manager = $container->get('entity_type.manager');
return new static(
$entity_type,
$entity_manager->getStorage($entity_type->id()),
$entity_manager->getDefinitions()
$entity_type_manager->getStorage($entity_type->id()),
$entity_type_manager->getDefinitions()
);
}
......
......@@ -4,8 +4,10 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Url;
......@@ -16,6 +18,14 @@
* Provides lists of field config entities.
*/
class FieldConfigListBuilder extends ConfigEntityListBuilder {
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = [
'entityManager' => 'entity.manager',
];
/**
* The name of the entity type the listed fields are attached to.
......@@ -32,11 +42,11 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
protected $targetBundle;
/**
* The entity manager.
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* The field type plugin manager.
......@@ -45,28 +55,47 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
*/
protected $fieldTypeManager;
/**
* The entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected $entityFieldManager;
/**
* Constructs a new class instance.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @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\Field\FieldTypePluginManagerInterface $field_type_manager
* The field type manager
* The field type manager.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface|null $entity_field_manager
* The entity field manager.
*/
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager) {
parent::__construct($entity_type, $entity_manager->getStorage($entity_type->id()));
public function __construct(EntityTypeInterface $entity_type, EntityTypeManagerInterface $entity_type_manager, FieldTypePluginManagerInterface $field_type_manager, EntityFieldManagerInterface $entity_field_manager = NULL) {
parent::__construct($entity_type, $entity_type_manager->getStorage($entity_type->id()));
$this->entityManager = $entity_manager;
$this->entityTypeManager = $entity_type_manager;
$this->fieldTypeManager = $field_type_manager;
if (!$entity_field_manager) {
@trigger_error('Calling FieldConfigListBuilder::__construct() with the $entity_field_manager argument is supported in Drupal 8.7.0 and will be required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$entity_field_manager = \Drupal::service('entity_field.manager');
}
$this->entityFieldManager = $entity_field_manager;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container->get('entity.manager'), $container->get('plugin.manager.field.field_type'));
return new static(
$entity_type,
$container->get('entity_type.manager'),
$container->get('plugin.manager.field.field_type'),
$container->get('entity_field.manager')
);
}
/**
......@@ -87,7 +116,7 @@ public function render($target_entity_type_id = NULL, $target_bundle = NULL) {
* {@inheritdoc}
*/
public function load() {
$entities = array_filter($this->entityManager->getFieldDefinitions($this->targetEntityTypeId, $this->targetBundle), function ($field_definition) {
$entities = array_filter($this->entityFieldManager->getFieldDefinitions($this->targetEntityTypeId, $this->targetBundle), function ($field_definition) {
return $field_definition instanceof FieldConfigInterface;
});
......@@ -120,7 +149,7 @@ public function buildRow(EntityInterface $field_config) {
$field_storage = $field_config->getFieldStorageDefinition();
$route_parameters = [
'field_config' => $field_config->id(),
] + FieldUI::getRouteBundleParameter($this->entityManager->getDefinition($this->targetEntityTypeId), $this->targetBundle);
] + FieldUI::getRouteBundleParameter($this->entityTypeManager->getDefinition($this->targetEntityTypeId), $this->targetBundle);
$row = [
'id' => Html::getClass($field_config->getName()),
......
......@@ -3,8 +3,9 @@
namespace Drupal\field_ui;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
......@@ -17,6 +18,14 @@
* @see field_ui_entity_info()
*/
class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = [
'entityManager' => 'entity.manager',
];
/**
* An array of information about field types.
......@@ -26,11 +35,11 @@ class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
protected $fieldTypes;
/**
* The entity manager.
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* An array of entity bundle information.
......@@ -51,15 +60,15 @@ class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager.
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
* The 'field type' plugin manager.
*/
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, EntityTypeBundleInfoInterface $bundle_info_service) {
parent::__construct($entity_type, $entity_manager->getStorage($entity_type->id()));
public function __construct(EntityTypeInterface $entity_type, EntityTypeManagerInterface $entity_type_manager, FieldTypePluginManagerInterface $field_type_manager, EntityTypeBundleInfoInterface $bundle_info_service) {
parent::__construct($entity_type, $entity_type_manager->getStorage($entity_type->id()));
$this->entityManager = $entity_manager;
$this->entityTypeManager = $entity_type_manager;
$this->bundles = $bundle_info_service->getAllBundleInfo();
$this->fieldTypeManager = $field_type_manager;
$this->fieldTypes = $this->fieldTypeManager->getDefinitions();
......@@ -71,7 +80,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityManagerInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager'),
$container->get('entity_type.manager'),
$container->get('plugin.manager.field.field_type'),
$container->get('entity_type.bundle.info')
);
......
......@@ -62,7 +62,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('config.factory'),
$container->get('messenger')
);
......
......@@ -51,7 +51,7 @@ class LanguageListBuilder extends DraggableListBuilder {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('language_manager'),
$container->get('config.factory'),
$container->get('messenger')
......
......@@ -62,12 +62,13 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
$entity_type_manager = $container->get('entity_type.manager');
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$entity_type_manager->getStorage($entity_type->id()),
$container->get('date.formatter'),
$container->get('language_manager'),
$container->get('entity_type.manager')->getStorage('image_style')
$entity_type_manager->getStorage('image_style')
);
}
......
......@@ -50,7 +50,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('date.formatter'),
$container->get('redirect.destination')
);
......
......@@ -77,7 +77,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('plugin.manager.search'),
$container->get('config.factory'),
$container->get('messenger')
......
......@@ -45,7 +45,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('date.formatter')
);
}
......
......@@ -47,7 +47,7 @@ public function __construct(EntityTypeInterface $entityType,
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('messenger')
);
}
......
......@@ -56,7 +56,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('date.formatter'),
$container->get('redirect.destination')
);
......
......@@ -36,7 +36,7 @@ class ViewListBuilder extends ConfigEntityListBuilder {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('plugin.manager.views.display')
);
}
......
......@@ -48,7 +48,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('workspaces.manager')
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment