Issue #2427637 by Mile23, keopx, naveenvalecha, marvin_B8: Remove usages of deprecated entity_get_bundles()
parent
b2b8aeaa61
commit
3700d9fd91
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\Core\Entity\Plugin\DataType\Deriver;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfo;
|
||||
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
|
@ -32,6 +33,13 @@ class EntityDeriver implements ContainerDeriverInterface {
|
|||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* The bundle info service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeBundleInfo
|
||||
*/
|
||||
protected $bundleInfoService;
|
||||
|
||||
/**
|
||||
* Constructs an EntityDeriver object.
|
||||
*
|
||||
|
@ -40,9 +48,10 @@ class EntityDeriver implements ContainerDeriverInterface {
|
|||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
*/
|
||||
public function __construct($base_plugin_id, EntityManagerInterface $entity_manager) {
|
||||
public function __construct($base_plugin_id, EntityManagerInterface $entity_manager, EntityTypeBundleInfo $bundle_info_service) {
|
||||
$this->basePluginId = $base_plugin_id;
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->bundleInfoService = $bundle_info_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +60,8 @@ class EntityDeriver implements ContainerDeriverInterface {
|
|||
public static function create(ContainerInterface $container, $base_plugin_id) {
|
||||
return new static(
|
||||
$base_plugin_id,
|
||||
$container->get('entity.manager')
|
||||
$container->get('entity.manager'),
|
||||
$container->get('entity_type.bundle.info')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -82,7 +92,7 @@ class EntityDeriver implements ContainerDeriverInterface {
|
|||
) + $base_plugin_definition;
|
||||
|
||||
// Incorporate the bundles as entity:$entity_type:$bundle, if any.
|
||||
foreach (entity_get_bundles($entity_type_id) as $bundle => $bundle_info) {
|
||||
foreach ($this->bundleInfoService->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
|
||||
if ($bundle !== $entity_type_id) {
|
||||
$this->derivatives[$entity_type_id . ':' . $bundle] = array(
|
||||
'label' => $bundle_info['label'],
|
||||
|
|
|
@ -51,7 +51,7 @@ function contact_entity_type_alter(array &$entity_types) {
|
|||
*/
|
||||
function contact_entity_extra_field_info() {
|
||||
$fields = array();
|
||||
foreach (array_keys(entity_get_bundles('contact_message')) as $bundle) {
|
||||
foreach (array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo('contact_message')) as $bundle) {
|
||||
$fields['contact_message'][$bundle]['form']['name'] = array(
|
||||
'label' => t('Sender name'),
|
||||
'description' => t('Text'),
|
||||
|
|
|
@ -93,12 +93,13 @@ function _content_translation_form_language_content_settings_form_alter(array &$
|
|||
$form['#attached']['library'][] = 'content_translation/drupal.content_translation.admin';
|
||||
|
||||
$entity_manager = Drupal::entityManager();
|
||||
$bundle_info_service = \Drupal::service('entity_type.bundle.info');
|
||||
foreach ($form['#labels'] as $entity_type_id => $label) {
|
||||
$entity_type = $entity_manager->getDefinition($entity_type_id);
|
||||
$storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : array();
|
||||
|
||||
$entity_type_translatable = $content_translation_manager->isSupported($entity_type_id);
|
||||
foreach (entity_get_bundles($entity_type_id) as $bundle => $bundle_info) {
|
||||
foreach ($bundle_info_service->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
|
||||
// Here we do not want the widget to be altered and hold also the "Enable
|
||||
// translation" checkbox, which would be redundant. Hence we add this key
|
||||
// to be able to skip alterations. Alter the title and display the message
|
||||
|
|
|
@ -351,9 +351,9 @@ function content_translation_language_fallback_candidates_entity_view_alter(&$ca
|
|||
*/
|
||||
function content_translation_entity_extra_field_info() {
|
||||
$extra = array();
|
||||
|
||||
$bundle_info_service = \Drupal::service('entity_type.bundle.info');
|
||||
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $info) {
|
||||
foreach (entity_get_bundles($entity_type) as $bundle => $bundle_info) {
|
||||
foreach ($bundle_info_service->getBundleInfo($entity_type) as $bundle => $bundle_info) {
|
||||
if (\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle)) {
|
||||
$extra[$entity_type][$bundle]['form']['translation'] = array(
|
||||
'label' => t('Translation'),
|
||||
|
|
|
@ -94,7 +94,7 @@ class EntityReferenceAdminTest extends WebTestBase {
|
|||
|
||||
// The base handler settings should be displayed.
|
||||
$entity_type_id = 'node';
|
||||
$bundles = entity_get_bundles($entity_type_id);
|
||||
$bundles = $this->container->get('entity_type.bundle.info')->getBundleInfo($entity_type_id);
|
||||
foreach ($bundles as $bundle_name => $bundle_info) {
|
||||
$this->assertFieldByName('settings[handler_settings][target_bundles][' . $bundle_name . ']');
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\field_ui;
|
|||
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfo;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Field\FieldTypePluginManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
@ -55,11 +56,11 @@ class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
|
|||
* @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) {
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, EntityTypeBundleInfo $bundle_info_service) {
|
||||
parent::__construct($entity_type, $entity_manager->getStorage($entity_type->id()));
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->bundles = entity_get_bundles();
|
||||
$this->bundles = $bundle_info_service->getAllBundleInfo();
|
||||
$this->fieldTypeManager = $field_type_manager;
|
||||
$this->fieldTypes = $this->fieldTypeManager->getDefinitions();
|
||||
}
|
||||
|
@ -71,7 +72,8 @@ class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
|
|||
return new static(
|
||||
$entity_type,
|
||||
$container->get('entity.manager'),
|
||||
$container->get('plugin.manager.field.field_type')
|
||||
$container->get('plugin.manager.field.field_type'),
|
||||
$container->get('entity_type.bundle.info')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class FileNormalizeTest extends NormalizerTestBase {
|
|||
$this->installEntitySchema('file');
|
||||
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
|
||||
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
|
||||
|
||||
// Set up the mock serializer.
|
||||
$normalizers = array(
|
||||
|
|
|
@ -131,7 +131,7 @@ abstract class NormalizerTestBase extends KernelTestBase {
|
|||
])->save();
|
||||
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
|
||||
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
|
||||
|
||||
$chain_resolver = new ChainEntityResolver(array(new UuidResolver($entity_manager), new TargetIdResolver()));
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ class Node extends WizardPluginBase {
|
|||
// entities. If a particular entity type (i.e., bundle) has been
|
||||
// selected above, then we only search for taxonomy fields associated
|
||||
// with that bundle. Otherwise, we use all bundles.
|
||||
$bundles = array_keys(entity_get_bundles($this->entityTypeId));
|
||||
$bundles = array_keys($this->bundleInfoService->getBundleInfo($this->entityTypeId));
|
||||
// Double check that this is a real bundle before using it (since above
|
||||
// we added a dummy option 'all' to the bundle list on the form).
|
||||
if (isset($selected_bundle) && in_array($selected_bundle, $bundles)) {
|
||||
|
|
|
@ -16,7 +16,7 @@ services:
|
|||
arguments: ['@rest.link_manager.type', '@rest.link_manager.relation']
|
||||
rest.link_manager.type:
|
||||
class: Drupal\rest\LinkManager\TypeLinkManager
|
||||
arguments: ['@cache.default', '@module_handler', '@config.factory', '@request_stack']
|
||||
arguments: ['@cache.default', '@module_handler', '@config.factory', '@request_stack', '@entity_type.bundle.info']
|
||||
rest.link_manager.relation:
|
||||
class: Drupal\rest\LinkManager\RelationLinkManager
|
||||
arguments: ['@cache.default', '@entity.manager', '@module_handler', '@config.factory', '@request_stack']
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\rest\LinkManager;
|
|||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfo;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
|
@ -24,6 +25,13 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
|
|||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* The bundle info service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeBundleInfo
|
||||
*/
|
||||
protected $bundleInfoService;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -35,12 +43,15 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
|
|||
* The config factory service.
|
||||
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
|
||||
* The request stack.
|
||||
* @param \Drupal\Core\Entity\EntityTypeBundleInfo $bundle_info_service
|
||||
* The bundle info service.
|
||||
*/
|
||||
public function __construct(CacheBackendInterface $cache, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, RequestStack $request_stack) {
|
||||
public function __construct(CacheBackendInterface $cache, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, RequestStack $request_stack, EntityTypeBundleInfo $bundle_info_service) {
|
||||
$this->cache = $cache;
|
||||
$this->configFactory = $config_factory;
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->requestStack = $request_stack;
|
||||
$this->bundleInfoService = $bundle_info_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +124,7 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
|
|||
// Type URIs correspond to bundles. Iterate through the bundles to get the
|
||||
// URI and data for them.
|
||||
$entity_types = \Drupal::entityManager()->getDefinitions();
|
||||
foreach (entity_get_bundles() as $entity_type_id => $bundles) {
|
||||
foreach ($this->bundleInfoService->getAllBundleInfo() as $entity_type_id => $bundles) {
|
||||
// Only content entities are supported currently.
|
||||
// @todo Consider supporting config entities.
|
||||
if ($entity_types[$entity_type_id]->isSubclassOf('\Drupal\Core\Config\Entity\ConfigEntityInterface')) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\views\Plugin\views\filter;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfo;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
@ -37,6 +38,13 @@ class Bundle extends InOperator {
|
|||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* The bundle info service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeBundleInfo
|
||||
*/
|
||||
protected $bundleInfoService;
|
||||
|
||||
/**
|
||||
* Constructs a Bundle object.
|
||||
*
|
||||
|
@ -49,10 +57,11 @@ class Bundle extends InOperator {
|
|||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, EntityTypeBundleInfo $bundle_info_service) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->bundleInfoService = $bundle_info_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +72,8 @@ class Bundle extends InOperator {
|
|||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity.manager')
|
||||
$container->get('entity.manager'),
|
||||
$container->get('entity_type.bundle.info')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -83,7 +93,7 @@ class Bundle extends InOperator {
|
|||
*/
|
||||
public function getValueOptions() {
|
||||
if (!isset($this->valueOptions)) {
|
||||
$types = entity_get_bundles($this->entityTypeId);
|
||||
$types = $this->bundleInfoService->getBundleInfo($this->entityTypeId);
|
||||
$this->valueTitle = $this->t('@entity types', array('@entity' => $this->entityType->getLabel()));
|
||||
|
||||
$options = array();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\views\Plugin\views\wizard;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfo;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Routing\UrlGeneratorTrait;
|
||||
use Drupal\views\Entity\View;
|
||||
|
@ -10,6 +11,7 @@ use Drupal\views\Views;
|
|||
use Drupal\views_ui\ViewUI;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Drupal\views\Plugin\views\PluginBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @defgroup views_wizard_plugins Views wizard plugins
|
||||
|
@ -108,12 +110,32 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
'group' => 1,
|
||||
);
|
||||
|
||||
/**
|
||||
* The bundle info service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeBundleInfo
|
||||
*/
|
||||
protected $bundleInfoService;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('entity_type.bundle.info')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a WizardPluginBase object.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeBundleInfo $bundle_info_service) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->bundleInfoService = $bundle_info_service;
|
||||
$this->base_table = $this->definition['base_table'];
|
||||
|
||||
$entity_types = \Drupal::entityManager()->getDefinitions();
|
||||
|
@ -585,7 +607,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
protected function buildFilters(&$form, FormStateInterface $form_state) {
|
||||
module_load_include('inc', 'views_ui', 'admin');
|
||||
|
||||
$bundles = entity_get_bundles($this->entityTypeId);
|
||||
$bundles = $this->bundleInfoService->getBundleInfo($this->entityTypeId);
|
||||
// If the current base table support bundles and has more than one (like user).
|
||||
if (!empty($bundles) && $this->entityType && $this->entityType->hasKey('bundle')) {
|
||||
// Get all bundles and their human readable names.
|
||||
|
|
|
@ -50,7 +50,7 @@ class FilterEntityBundleTest extends ViewTestBase {
|
|||
|
||||
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
|
||||
|
||||
$this->entityBundles = entity_get_bundles('node');
|
||||
$this->entityBundles = $this->container->get('entity_type.bundle.info')->getBundleInfo('node');
|
||||
|
||||
$this->entities['count'] = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue