Unverified Commit cc5b5dc3 authored by alexpott's avatar alexpott
Browse files

Issue #3023799 by Berdir, alexpott, tim.plunkett, larowlan: Add...

Issue #3023799 by Berdir, alexpott, tim.plunkett, larowlan: Add @trigger_error() to deprecated EntityManager::clearCachedDefinitions() method
parent 242bffc0
......@@ -548,9 +548,6 @@ services:
# rely on this service and they would fail with deprecation warnings.
class: Drupal\Core\Entity\EntityManager
parent: container.trait
# @todo Remove this tag in https://www.drupal.org/node/2549143.
tags:
- { name: plugin_manager_cache_clear }
entity.memory_cache:
class: Drupal\Core\Cache\MemoryCache\MemoryCache
entity_type.manager:
......
......@@ -31,6 +31,7 @@ class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
* @see https://www.drupal.org/node/2549139
*/
public function clearCachedDefinitions() {
@trigger_error('EntityManagerInterface::clearCachedDefinitions() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityTypeManagerInterface::clearCachedDefinitions() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->container->get('entity_type.manager')->clearCachedDefinitions();
// @todo None of these are plugin managers, and they should not co-opt
......
......@@ -400,6 +400,6 @@ function content_translation_form_language_content_settings_submit(array $form,
}
// Ensure entity and menu router information are correctly rebuilt.
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::entityTypeManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->setRebuildNeeded();
}
......@@ -591,7 +591,7 @@ function content_translation_language_configuration_element_submit(array $form,
if (\Drupal::service('content_translation.manager')->isEnabled($context['entity_type'], $context['bundle']) != $enabled) {
\Drupal::service('content_translation.manager')->setEnabled($context['entity_type'], $context['bundle'], $enabled);
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::entityTypeManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->setRebuildNeeded();
}
}
......
......@@ -50,7 +50,6 @@ protected function setUp() {
// picked up.
\Drupal::service('content_translation.manager')->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->rebuild();
\Drupal::service('entity.definition_update_manager')->applyUpdates();
......
......@@ -238,7 +238,6 @@ protected function assertSettings($entity_type, $bundle, $enabled, $edit) {
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$args = ['@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled'];
$message = format_string('Translation for entity @entity_type (@bundle) is @enabled.', $args);
\Drupal::entityManager()->clearCachedDefinitions();
return $this->assertEqual(\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle), $enabled, $message);
}
......
......@@ -169,7 +169,6 @@ protected function enableTranslation() {
// picked up.
\Drupal::service('content_translation.manager')->setEnabled($this->entityTypeId, $this->bundle, TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->rebuild();
\Drupal::service('entity.definition_update_manager')->applyUpdates();
}
......
......@@ -90,8 +90,6 @@ protected function setUp() {
$field_config->setThirdPartySetting('content_translation', 'translation_sync', $property_settings);
$field_config->save();
$this->entityManager->clearCachedDefinitions();
$this->contentTranslationManager = $this->container->get('content_translation.manager');
$this->contentTranslationManager->setEnabled($entity_type_id, $entity_type_id, TRUE);
......
......@@ -21,13 +21,13 @@ function field_test_entity_type_alter(array &$entity_types) {
function field_test_entity_info_translatable($entity_type_id = NULL, $translatable = NULL) {
$stored_value = &drupal_static(__FUNCTION__, []);
if (isset($entity_type_id)) {
$entity_manager = \Drupal::entityManager();
$original = $entity_manager->getDefinition($entity_type_id);
$entity_type_manager = \Drupal::entityTypeManager();
$original = $entity_type_manager->getDefinition($entity_type_id);
$stored_value[$entity_type_id] = $translatable;
if ($translatable != $original->isTranslatable()) {
$entity_manager->clearCachedDefinitions();
$entity_type = $entity_manager->getDefinition($entity_type_id);
$entity_manager->onEntityTypeUpdate($entity_type, $original);
$entity_type_manager->clearCachedDefinitions();
$entity_type = $entity_type_manager->getDefinition($entity_type_id);
\Drupal::service('entity_type.listener')->onEntityTypeUpdate($entity_type, $original);
}
}
return $stored_value;
......
......@@ -223,7 +223,6 @@ protected function enableTranslation() {
\Drupal::service('content_translation.manager')->setEnabled($this->testEntityTypeName, $this->referrerType->id(), TRUE);
\Drupal::service('content_translation.manager')->setEnabled($this->testEntityTypeName, $this->referencedType->id(), TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->rebuild();
\Drupal::service('entity.definition_update_manager')->applyUpdates();
}
......
......@@ -23,7 +23,7 @@ public function testFileAccessHandler() {
$field_name = strtolower($this->randomMachineName());
$this->createFileField($field_name, 'node', $type_name);
\Drupal::state()->set('file_test_alternate_access_handler', TRUE);
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::entityTypeManager()->clearCachedDefinitions();
$test_file = $this->getTestFile('text');
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$this->drupalGet('node/' . $nid);
......
......@@ -74,7 +74,6 @@ protected function setUp() {
"settings[node][page][fields][$this->fieldName]" => 1,
];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
}
/**
......
......@@ -63,7 +63,6 @@ protected function setUp() {
"settings[node][page][fields][$this->fieldName]" => 1,
];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
}
/**
......
......@@ -61,7 +61,6 @@ protected function setUp() {
'settings[node][page][settings][language][language_alterable]' => 1,
];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
$definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'page');
$this->assertTrue($definitions['path']->isTranslatable(), 'Node path is translatable.');
......
......@@ -15,7 +15,6 @@ trait EntityDefinitionTestTrait {
*/
protected function enableNewEntityType() {
$this->state->set('entity_test_new', TRUE);
$this->entityManager->clearCachedDefinitions();
$this->entityDefinitionUpdateManager->applyUpdates();
}
......@@ -24,7 +23,6 @@ protected function enableNewEntityType() {
*/
protected function resetEntityType() {
$this->state->set('entity_test_update.entity_type', NULL);
$this->entityManager->clearCachedDefinitions();
$this->entityDefinitionUpdateManager->applyUpdates();
}
......@@ -32,7 +30,7 @@ protected function resetEntityType() {
* Updates the 'entity_test_update' entity type to revisionable.
*/
protected function updateEntityTypeToRevisionable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$keys = $entity_type->getKeys();
$keys['revision'] = 'revision_id';
......@@ -46,7 +44,7 @@ protected function updateEntityTypeToRevisionable() {
* Updates the 'entity_test_update' entity type not revisionable.
*/
protected function updateEntityTypeToNotRevisionable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$keys = $entity_type->getKeys();
unset($keys['revision']);
......@@ -60,7 +58,7 @@ protected function updateEntityTypeToNotRevisionable() {
* Updates the 'entity_test_update' entity type to translatable.
*/
protected function updateEntityTypeToTranslatable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$entity_type->set('translatable', TRUE);
$entity_type->set('data_table', 'entity_test_update_data');
......@@ -76,7 +74,7 @@ protected function updateEntityTypeToTranslatable() {
* Updates the 'entity_test_update' entity type to not translatable.
*/
protected function updateEntityTypeToNotTranslatable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$entity_type->set('translatable', FALSE);
$entity_type->set('data_table', NULL);
......@@ -93,7 +91,7 @@ protected function updateEntityTypeToNotTranslatable() {
* translatable.
*/
protected function updateEntityTypeToRevisionableAndTranslatable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$keys = $entity_type->getKeys();
$keys['revision'] = 'revision_id';
......@@ -165,7 +163,7 @@ protected function modifyBaseField() {
* Promotes a field to an entity key.
*/
protected function makeBaseFieldEntityKey() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$entity_keys = $entity_type->getKeys();
$entity_keys['new_base_field'] = 'new_base_field';
$entity_type->set('entity_keys', $entity_keys);
......@@ -249,7 +247,7 @@ protected function removeEntityIndex() {
* Renames the base table to 'entity_test_update_new'.
*/
protected function renameBaseTable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$entity_type->set('base_table', 'entity_test_update_new');
......@@ -260,7 +258,7 @@ protected function renameBaseTable() {
* Renames the data table to 'entity_test_update_data_new'.
*/
protected function renameDataTable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$entity_type->set('data_table', 'entity_test_update_data_new');
......@@ -271,7 +269,7 @@ protected function renameDataTable() {
* Renames the revision table to 'entity_test_update_revision_new'.
*/
protected function renameRevisionBaseTable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$entity_type->set('revision_table', 'entity_test_update_revision_new');
......@@ -282,7 +280,7 @@ protected function renameRevisionBaseTable() {
* Renames the revision data table to 'entity_test_update_revision_data_new'.
*/
protected function renameRevisionDataTable() {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone \Drupal::entityTypeManager()->getDefinition('entity_test_update');
$entity_type->set('revision_data_table', 'entity_test_update_revision_data_new');
......
......@@ -66,7 +66,6 @@ protected function enableTranslation() {
\Drupal::service('content_translation.manager')->setEnabled('node', 'article', TRUE);
\Drupal::service('content_translation.manager')->setEnabled('taxonomy_term', $this->vocabulary->id(), TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->rebuild();
\Drupal::service('entity.definition_update_manager')->applyUpdates();
}
......
......@@ -101,7 +101,6 @@ public function testTaxonomyTermView() {
->grantPermission('translate any entity')
->save();
drupal_static_reset();
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->rebuild();
\Drupal::service('entity.definition_update_manager')->applyUpdates();
......
......@@ -36,7 +36,6 @@ protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
/** @var \Drupal\Core\Entity\EntityDefinitionUpdateManager $update_manager */
$update_manager = $this->container->get('entity.definition_update_manager');
\Drupal::entityManager()->clearCachedDefinitions();
$update_manager->applyUpdates();
ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
\Drupal::state()->set('entity_test.views_data', [
......
......@@ -54,7 +54,6 @@ public function testMultilingualSearchFilter() {
'settings[node][' . $type->id() . '][fields][body]' => TRUE,
];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
// Add a node in English, with title "sandwich".
$values = [
......
......@@ -50,11 +50,11 @@ class ViewsEntitySchemaSubscriberIntegrationTest extends ViewsKernelTestBase {
protected $eventSubscriber;
/**
* The entity manager service.
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* The state service.
......@@ -72,14 +72,14 @@ protected function setUp($import_test_views = TRUE) {
$this->eventDispatcher = $this->container->get('event_dispatcher');
$this->eventSubscriber = $this->container->get('views.entity_schema_subscriber');
$this->entityDefinitionUpdateManager = $this->container->get('entity.definition_update_manager');
$this->entityManager = $this->container->get('entity.manager');
$this->entityTypeManager = $this->container->get('entity_type.manager');
$this->state = $this->container->get('state');
$this->database = $this->container->get('database');
// Install every entity type's schema that wasn't installed in the parent
// method.
foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(['user', 'entity_test'])) as $entity_type_id => $entity_type) {
foreach (array_diff_key($this->entityTypeManager->getDefinitions(), array_flip(['user', 'entity_test'])) as $entity_type_id => $entity_type) {
$this->installEntitySchema($entity_type_id);
}
}
......@@ -88,7 +88,7 @@ protected function setUp($import_test_views = TRUE) {
* Tests that views are disabled when an entity type is deleted.
*/
public function testDeleteEntityType() {
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
// Make the test entity type revisionable.
$this->updateEntityTypeToRevisionable();
......@@ -102,7 +102,7 @@ public function testDeleteEntityType() {
$this->assertTrue(isset($views['test_view_entity_test_data']));
$this->assertTrue(isset($views['test_view_entity_test_additional_base_field']));
$event = new EntityTypeEvent($this->entityManager->getDefinition('entity_test_update'));
$event = new EntityTypeEvent($this->entityTypeManager->getDefinition('entity_test_update'));
$this->eventDispatcher->dispatch(EntityTypeEvents::DELETE, $event);
// We expect that views which use 'entity_test_update' as base tables are
......@@ -131,7 +131,7 @@ public function testBaseTableRename() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test');
// Ensure the base table got renamed, so also the views fields.
......@@ -148,7 +148,7 @@ public function testDataTableRename() {
$this->updateEntityTypeToTranslatable();
$this->entityDefinitionUpdateManager->applyUpdates();
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_data');
$this->assertEqual('entity_test_update', $view->get('base_table'));
$display = $view->getDisplay('default');
......@@ -160,7 +160,7 @@ public function testDataTableRename() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_data');
// Ensure the data table got renamed, so also the views fields.
......@@ -178,7 +178,7 @@ public function testRevisionBaseTableRename() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_revision');
$this->assertEqual('entity_test_update_revision', $view->get('base_table'));
$display = $view->getDisplay('default');
......@@ -189,7 +189,7 @@ public function testRevisionBaseTableRename() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_revision');
// Ensure the base table got renamed, so also the views fields.
......@@ -206,12 +206,12 @@ public function testRevisionDataTableRename() {
$this->updateEntityTypeToRevisionable();
// Multiple changes, so we have to invalidate the caches, otherwise
// the second update will revert the first.
$this->entityManager->clearCachedDefinitions();
$this->entityTypeManager->clearCachedDefinitions();
$this->updateEntityTypeToTranslatable();
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_revision');
$this->assertEqual('entity_test_update_revision', $view->get('base_table'));
$display = $view->getDisplay('default');
......@@ -222,7 +222,7 @@ public function testRevisionDataTableRename() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_revision');
// Ensure the base table got renamed, so also the views fields.
......@@ -240,7 +240,7 @@ public function testDataTableAddition() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test');
// Ensure the data table got renamed, so also the views fields.
......@@ -258,7 +258,7 @@ public function testRevisionEnabling() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test');
// Ensure that nothing happens.
......@@ -279,7 +279,7 @@ public function testRevisionDisabling() {
$this->entityDefinitionUpdateManager->applyUpdates();
/** @var \Drupal\views\Entity\View $view */
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
$view = $entity_storage->load('test_view_entity_test_revision');
$this->assertFalse($view->status());
......@@ -415,7 +415,7 @@ public function testVariousTableUpdatesForRevisionView() {
$this->updateEntityTypeToRevisionable();
// Multiple changes, so we have to invalidate the caches, otherwise
// the second update will revert the first.
$this->entityManager->clearCachedDefinitions();
$this->entityTypeManager->clearCachedDefinitions();
list($view, $display) = $this->getUpdatedViewAndDisplay(TRUE);
......@@ -452,7 +452,7 @@ public function testVariousTableUpdatesForRevisionView() {
* An array with the view as first item, and the display as second.
*/
protected function getUpdatedViewAndDisplay($revision = FALSE) {
$entity_storage = $this->entityManager->getStorage('view');
$entity_storage = $this->entityTypeManager->getStorage('view');
/** @var \Drupal\views\Entity\View $view */
$view = $entity_storage->load($revision ? 'test_view_entity_test_revision' : 'test_view_entity_test');
$display = $view->getDisplay('default');
......
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