Issue #3047866 by mikelutz, Berdir, TR, alexpott, andypost, Satyanarayan Reddy: Remove usage of deprecated \Drupal::entityManager() in core
parent
5ad7fe3212
commit
ba509afbc9
|
@ -1914,7 +1914,7 @@ function hook_cron() {
|
|||
// Long-running operation example, leveraging a queue:
|
||||
// Queue news feeds for updates once their refresh interval has elapsed.
|
||||
$queue = \Drupal::queue('aggregator_feeds');
|
||||
$ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh();
|
||||
$ids = \Drupal::entityTypeManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh();
|
||||
foreach (Feed::loadMultiple($ids) as $feed) {
|
||||
if ($queue->createItem($feed)) {
|
||||
// Add timestamp to avoid queueing item more than once.
|
||||
|
|
|
@ -1621,7 +1621,7 @@ function install_profile_modules(&$install_state) {
|
|||
*/
|
||||
function install_core_entity_type_definitions() {
|
||||
$update_manager = \Drupal::entityDefinitionUpdateManager();
|
||||
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type) {
|
||||
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type) {
|
||||
if ($entity_type->getProvider() == 'core') {
|
||||
$update_manager->installEntityType($entity_type);
|
||||
}
|
||||
|
|
|
@ -270,6 +270,7 @@ class Drupal {
|
|||
* correct interface or service.
|
||||
*/
|
||||
public static function entityManager() {
|
||||
@trigger_error("\Drupal::entityManager() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager() instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service. See https://www.drupal.org/node/2549139", E_USER_DEPRECATED);
|
||||
return static::getContainer()->get('entity.manager');
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
|
|||
->execute();
|
||||
|
||||
// Load the first valid candidate display, if any.
|
||||
$storage = \Drupal::entityManager()->getStorage('entity_form_display');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('entity_form_display');
|
||||
foreach ($candidate_ids as $candidate_id) {
|
||||
if (isset($results[$candidate_id])) {
|
||||
$display = $storage->load($candidate_id);
|
||||
|
|
|
@ -112,7 +112,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
|
|||
}
|
||||
|
||||
// Load the selected displays.
|
||||
$storage = \Drupal::entityManager()->getStorage('entity_view_display');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
|
||||
$displays = $storage->loadMultiple($load_ids);
|
||||
|
||||
$displays_by_bundle = [];
|
||||
|
@ -182,8 +182,8 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
|
|||
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
|
||||
// Reset the render cache for the target entity type.
|
||||
parent::postSave($storage, $update);
|
||||
if (\Drupal::entityManager()->hasHandler($this->targetEntityType, 'view_builder')) {
|
||||
\Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache();
|
||||
if (\Drupal::entityTypeManager()->hasHandler($this->targetEntityType, 'view_builder')) {
|
||||
\Drupal::entityTypeManager()->getViewBuilder($this->targetEntityType)->resetCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ abstract class EntityDisplayModeBase extends ConfigEntityBase implements EntityD
|
|||
*/
|
||||
public function calculateDependencies() {
|
||||
parent::calculateDependencies();
|
||||
$target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType);
|
||||
$target_entity_type = \Drupal::entityTypeManager()->getDefinition($this->targetEntityType);
|
||||
$this->addDependency('module', $target_entity_type->getProvider());
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
|
|||
*
|
||||
* The following code returns the same object:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getDefinition($this->entityTypeId)
|
||||
* \Drupal::entityTypeManager()->getDefinition($this->entityTypeId)
|
||||
* @endcode
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
|
|
|
@ -910,7 +910,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
|
|||
// If this entity type uses entities to manage its bundles then depend on
|
||||
// the bundle entity.
|
||||
if ($bundle_entity_type_id = $this->getBundleEntityType()) {
|
||||
if (!$bundle_entity = \Drupal::entityManager()->getStorage($bundle_entity_type_id)->load($bundle)) {
|
||||
if (!$bundle_entity = \Drupal::entityTypeManager()->getStorage($bundle_entity_type_id)->load($bundle)) {
|
||||
throw new \LogicException(sprintf('Missing bundle entity, entity type %s, entity id %s.', $bundle_entity_type_id, $bundle));
|
||||
}
|
||||
$config_dependency = [
|
||||
|
|
|
@ -232,7 +232,7 @@ class EntityTypeManager extends DefaultPluginManager implements EntityTypeManage
|
|||
->setOperation($operation)
|
||||
// The entity manager cannot be injected due to a circular dependency.
|
||||
// @todo Remove this set call in https://www.drupal.org/node/2603542.
|
||||
->setEntityManager(\Drupal::entityManager());
|
||||
->setEntityManager(\Drupal::service('entity.manager'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ class EntityChangedConstraintValidator extends ConstraintValidator {
|
|||
if (isset($entity)) {
|
||||
/** @var \Drupal\Core\Entity\EntityInterface $entity */
|
||||
if (!$entity->isNew()) {
|
||||
$saved_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id());
|
||||
$saved_entity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id());
|
||||
// Ensure that all the entity translations are the same as or newer
|
||||
// than their current version in the storage in order to avoid
|
||||
// reverting other changes. In fact the entity object that is being
|
||||
|
|
|
@ -29,7 +29,7 @@ class ReferenceAccessConstraintValidator extends ConstraintValidator {
|
|||
$entity = $value->getEntity();
|
||||
$check_permission = TRUE;
|
||||
if (!$entity->isNew()) {
|
||||
$existing_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id());
|
||||
$existing_entity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id());
|
||||
$referenced_entities = $existing_entity->{$value->getFieldDefinition()->getName()}->referencedEntities();
|
||||
// Check permission if we are not already referencing the entity.
|
||||
foreach ($referenced_entities as $ref) {
|
||||
|
|
|
@ -70,7 +70,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
|
|||
if (!isset($this->propertyDefinitions)) {
|
||||
if ($entity_type_id = $this->getEntityTypeId()) {
|
||||
// Return an empty array for entities that are not content entities.
|
||||
$entity_type_class = \Drupal::entityManager()->getDefinition($entity_type_id)->getClass();
|
||||
$entity_type_class = \Drupal::entityTypeManager()->getDefinition($entity_type_id)->getClass();
|
||||
if (!in_array('Drupal\Core\Entity\FieldableEntityInterface', class_implements($entity_type_class))) {
|
||||
$this->propertyDefinitions = [];
|
||||
}
|
||||
|
|
|
@ -580,7 +580,7 @@ use Drupal\node\Entity\NodeType;
|
|||
* implementing \Drupal\Core\Entity\EntityViewBuilderInterface that you can
|
||||
* retrieve with:
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityManager()->getViewBuilder('your_entity_type');
|
||||
* $view_builder = \Drupal::entityTypeManager()->getViewBuilder('your_entity_type');
|
||||
* // Or if you have a $container variable:
|
||||
* $view_builder = $container->get('entity.manager')->getViewBuilder('your_entity_type');
|
||||
* @endcode
|
||||
|
@ -1943,7 +1943,7 @@ function hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\Entit
|
|||
* @see \Drupal\Core\Entity\EntityManagerInterface::getFieldStorageDefinitions()
|
||||
*/
|
||||
function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
|
||||
if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
|
||||
if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
|
||||
// Query by filtering on the ID as this is more efficient than filtering
|
||||
// on the entity_type property directly.
|
||||
$ids = \Drupal::entityQuery('field_storage_config')
|
||||
|
|
|
@ -729,7 +729,7 @@ function hook_post_update_NAME(&$sandbox) {
|
|||
$block_update_8001 = \Drupal::keyValue('update_backup')->get('block_update_8001', []);
|
||||
|
||||
$block_ids = array_keys($block_update_8001);
|
||||
$block_storage = \Drupal::entityManager()->getStorage('block');
|
||||
$block_storage = \Drupal::entityTypeManager()->getStorage('block');
|
||||
$blocks = $block_storage->loadMultiple($block_ids);
|
||||
/** @var $blocks \Drupal\block\BlockInterface[] */
|
||||
foreach ($blocks as $block) {
|
||||
|
|
|
@ -64,7 +64,7 @@ class BaseFieldOverride extends FieldConfigBase {
|
|||
$values = $base_field_definition->toArray();
|
||||
$values['bundle'] = $bundle;
|
||||
$values['baseFieldDefinition'] = $base_field_definition;
|
||||
return \Drupal::entityManager()->getStorage('base_field_override')->create($values);
|
||||
return \Drupal::entityTypeManager()->getStorage('base_field_override')->create($values);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,7 +238,7 @@ class BaseFieldOverride extends FieldConfigBase {
|
|||
* provided field name, otherwise NULL.
|
||||
*/
|
||||
public static function loadByName($entity_type_id, $bundle, $field_name) {
|
||||
return \Drupal::entityManager()->getStorage('base_field_override')->load($entity_type_id . '.' . $bundle . '.' . $field_name);
|
||||
return \Drupal::entityTypeManager()->getStorage('base_field_override')->load($entity_type_id . '.' . $bundle . '.' . $field_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,7 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere
|
|||
// Load and add the existing entities.
|
||||
if ($ids) {
|
||||
$target_type = $this->getFieldDefinition()->getSetting('target_type');
|
||||
$entities = \Drupal::entityManager()->getStorage($target_type)->loadMultiple($ids);
|
||||
$entities = \Drupal::entityTypeManager()->getStorage($target_type)->loadMultiple($ids);
|
||||
foreach ($ids as $delta => $target_id) {
|
||||
if (isset($entities[$target_id])) {
|
||||
$target_entities[$delta] = $entities[$target_id];
|
||||
|
@ -75,7 +75,7 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere
|
|||
$entity_ids = \Drupal::entityQuery($target_type)
|
||||
->condition('uuid', $uuids, 'IN')
|
||||
->execute();
|
||||
$entities = \Drupal::entityManager()
|
||||
$entities = \Drupal::entityTypeManager()
|
||||
->getStorage($target_type)
|
||||
->loadMultiple($entity_ids);
|
||||
|
||||
|
@ -117,7 +117,7 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere
|
|||
}
|
||||
$ids[] = $default_value[$delta]['target_id'];
|
||||
}
|
||||
$entities = \Drupal::entityManager()
|
||||
$entities = \Drupal::entityTypeManager()
|
||||
->getStorage($this->getSetting('target_type'))
|
||||
->loadMultiple($ids);
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function view($display_options = []) {
|
||||
$view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId());
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->getEntity()->getEntityTypeId());
|
||||
return $view_builder->viewFieldItem($this, $display_options);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE) {
|
||||
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->getEntity()->getEntityTypeId());
|
||||
$access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler($this->getEntity()->getEntityTypeId());
|
||||
return $access_control_handler->fieldAccess($operation, $this->getFieldDefinition(), $account, $this, $return_as_object);
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function view($display_options = []) {
|
||||
$view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId());
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->getEntity()->getEntityTypeId());
|
||||
return $view_builder->viewField($this, $display_options);
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
|
|||
// This formatter is only available for entity types that have a view
|
||||
// builder.
|
||||
$target_type = $field_definition->getFieldStorageDefinition()->getSetting('target_type');
|
||||
return \Drupal::entityManager()->getDefinition($target_type)->hasViewBuilderClass();
|
||||
return \Drupal::entityTypeManager()->getDefinition($target_type)->hasViewBuilderClass();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ abstract class EntityReferenceFormatterBase extends FormatterBase {
|
|||
}
|
||||
if ($ids) {
|
||||
$target_type = $this->getFieldSetting('target_type');
|
||||
$target_entities = \Drupal::entityManager()->getStorage($target_type)->loadMultiple($ids);
|
||||
$target_entities = \Drupal::entityTypeManager()->getStorage($target_type)->loadMultiple($ids);
|
||||
}
|
||||
|
||||
// For each item, pre-populate the loaded entity in $item->entity, and set
|
||||
|
|
|
@ -400,7 +400,7 @@ function hook_contextual_links_alter(array &$links, $group, array $route_paramet
|
|||
if ($group == 'menu') {
|
||||
// Dynamically use the menu name for the title of the menu_edit contextual
|
||||
// link.
|
||||
$menu = \Drupal::entityManager()->getStorage('menu')->load($route_parameters['menu']);
|
||||
$menu = \Drupal::entityTypeManager()->getStorage('menu')->load($route_parameters['menu']);
|
||||
$links['menu_edit']['title'] = t('Edit menu: @label', ['@label' => $menu->label()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ class AccountProxy implements AccountProxyInterface {
|
|||
* An account or NULL if none is found.
|
||||
*/
|
||||
protected function loadUserEntity($account_id) {
|
||||
return \Drupal::entityManager()->getStorage('user')->load($account_id);
|
||||
return \Drupal::entityTypeManager()->getStorage('user')->load($account_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ class UserSession implements AccountInterface {
|
|||
* The role storage object.
|
||||
*/
|
||||
protected function getRoleStorage() {
|
||||
return \Drupal::entityManager()->getStorage('user_role');
|
||||
return \Drupal::entityTypeManager()->getStorage('user_role');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ function aggregator_entity_extra_field_info() {
|
|||
function aggregator_cron() {
|
||||
$queue = \Drupal::queue('aggregator_feeds');
|
||||
|
||||
$ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh();
|
||||
$ids = \Drupal::entityTypeManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh();
|
||||
foreach (Feed::loadMultiple($ids) as $feed) {
|
||||
if ($queue->createItem($feed)) {
|
||||
// Add timestamp to avoid queueing item more than once.
|
||||
|
|
|
@ -125,7 +125,7 @@ class Feed extends ContentEntityBase implements FeedInterface {
|
|||
->condition('settings.feed', array_keys($entities))
|
||||
->execute();
|
||||
if ($ids) {
|
||||
$block_storage = \Drupal::entityManager()->getStorage('block');
|
||||
$block_storage = \Drupal::entityTypeManager()->getStorage('block');
|
||||
$block_storage->delete($block_storage->loadMultiple($ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class FeedProcessorPluginTest extends AggregatorTestBase {
|
|||
$this->updateFeedItems($feed);
|
||||
$feed_id = $feed->id();
|
||||
// Reset entity cache manually.
|
||||
\Drupal::entityManager()->getStorage('aggregator_feed')->resetCache([$feed_id]);
|
||||
\Drupal::entityTypeManager()->getStorage('aggregator_feed')->resetCache([$feed_id]);
|
||||
// Reload the feed to get new values.
|
||||
$feed = Feed::load($feed_id);
|
||||
// Make sure its refresh rate doubled.
|
||||
|
|
|
@ -30,7 +30,7 @@ function block_post_update_disable_blocks_with_missing_contexts() {
|
|||
$block_update_8001 = \Drupal::keyValue('update_backup')->get('block_update_8001', []);
|
||||
|
||||
$block_ids = array_keys($block_update_8001);
|
||||
$block_storage = \Drupal::entityManager()->getStorage('block');
|
||||
$block_storage = \Drupal::entityTypeManager()->getStorage('block');
|
||||
$blocks = $block_storage->loadMultiple($block_ids);
|
||||
/** @var $blocks \Drupal\block\BlockInterface[] */
|
||||
foreach ($blocks as $block) {
|
||||
|
|
|
@ -132,7 +132,7 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
|
|||
// as in the original language.
|
||||
$default_langcode = $this->langcodes[0];
|
||||
$values = $this->getNewEntityValues($default_langcode);
|
||||
$storage = \Drupal::entityManager()->getStorage($this->entityTypeId);
|
||||
$storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId);
|
||||
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
$entity = $storage->create(['type' => 'basic'] + $values);
|
||||
$entity->save();
|
||||
|
|
|
@ -57,7 +57,7 @@ class PageEditTest extends BlockContentTestBase {
|
|||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
|
||||
// Ensure that the block revision has been created.
|
||||
\Drupal::entityManager()->getStorage('block_content')->resetCache([$block->id()]);
|
||||
\Drupal::entityTypeManager()->getStorage('block_content')->resetCache([$block->id()]);
|
||||
$revised_block = BlockContent::load($block->id());
|
||||
$this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.');
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ function book_node_links_alter(array &$links, NodeInterface $node, array &$conte
|
|||
if (isset($node->book['depth'])) {
|
||||
if ($context['view_mode'] == 'full' && node_is_page($node)) {
|
||||
$child_type = \Drupal::config('book.settings')->get('child_type');
|
||||
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node');
|
||||
$access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node');
|
||||
if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) {
|
||||
$book_links['book_add_child'] = [
|
||||
'title' => t('Add child page'),
|
||||
|
|
|
@ -118,7 +118,7 @@ class BookBreadcrumbTest extends BrowserTestBase {
|
|||
$edit['book[pid]'] = $parent;
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
// Make sure the parent was flagged as having children.
|
||||
$parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent);
|
||||
$parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent);
|
||||
$this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -405,7 +405,7 @@ class BookTest extends BrowserTestBase {
|
|||
$edit = [];
|
||||
$edit['book[bid]'] = '1';
|
||||
$this->drupalPostForm('node/' . $empty_book->id() . '/outline', $edit, t('Add to book outline'));
|
||||
$node = \Drupal::entityManager()->getStorage('node')->load($empty_book->id());
|
||||
$node = \Drupal::entityTypeManager()->getStorage('node')->load($empty_book->id());
|
||||
// Test the book array.
|
||||
$this->assertEqual($node->book['nid'], $empty_book->id());
|
||||
$this->assertEqual($node->book['bid'], $empty_book->id());
|
||||
|
@ -428,7 +428,7 @@ class BookTest extends BrowserTestBase {
|
|||
$edit = [];
|
||||
$edit['book[bid]'] = $node->id();
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
|
||||
$node = \Drupal::entityManager()->getStorage('node')->load($node->id());
|
||||
$node = \Drupal::entityTypeManager()->getStorage('node')->load($node->id());
|
||||
|
||||
// Test the book array.
|
||||
$this->assertEqual($node->book['nid'], $node->id());
|
||||
|
@ -519,7 +519,7 @@ class BookTest extends BrowserTestBase {
|
|||
$this->drupalLogin($this->bookAuthor);
|
||||
$this->book = $this->createBookNode('new');
|
||||
// Reset any internal static caching.
|
||||
$node_storage = \Drupal::entityManager()->getStorage('node');
|
||||
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
|
||||
$node_storage->resetCache();
|
||||
|
||||
// Log in as user without access to the book node, so no 'node test view'
|
||||
|
|
|
@ -198,7 +198,7 @@ trait BookTestTrait {
|
|||
$edit['book[pid]'] = $parent;
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
// Make sure the parent was flagged as having children.
|
||||
$parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent);
|
||||
$parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent);
|
||||
$this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -121,7 +121,7 @@ class BookRelationshipTest extends ViewTestBase {
|
|||
$edit['book[pid]'] = $parent;
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
// Make sure the parent was flagged as having children.
|
||||
$parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent);
|
||||
$parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent);
|
||||
$this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -177,7 +177,7 @@ function comment_field_config_update(FieldConfigInterface $field) {
|
|||
if ($field->getType() == 'comment') {
|
||||
// Comment field settings also affects the rendering of *comment* entities,
|
||||
// not only the *commented* entities.
|
||||
\Drupal::entityManager()->getViewBuilder('comment')->resetCache();
|
||||
\Drupal::entityTypeManager()->getViewBuilder('comment')->resetCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ function comment_form_field_ui_display_overview_form_alter(&$form, FormStateInte
|
|||
*/
|
||||
function comment_entity_storage_load($entities, $entity_type) {
|
||||
// Comments can only be attached to content entities, so skip others.
|
||||
if (!\Drupal::entityManager()->getDefinition($entity_type)->entityClassImplements(FieldableEntityInterface::class)) {
|
||||
if (!\Drupal::entityTypeManager()->getDefinition($entity_type)->entityClassImplements(FieldableEntityInterface::class)) {
|
||||
return;
|
||||
}
|
||||
if (!\Drupal::service('comment.manager')->getFields($entity_type)) {
|
||||
|
@ -426,7 +426,7 @@ function comment_entity_predelete(EntityInterface $entity) {
|
|||
* FALSE otherwise.
|
||||
*/
|
||||
function _comment_entity_uses_integer_id($entity_type_id) {
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
|
||||
$entity_type_id_key = $entity_type->getKey('id');
|
||||
if ($entity_type_id_key === FALSE) {
|
||||
return FALSE;
|
||||
|
@ -453,7 +453,7 @@ function comment_node_update_index(EntityInterface $node) {
|
|||
// edit could change the security situation so it is not safe to index the
|
||||
// comments.
|
||||
$index_comments = TRUE;
|
||||
$roles = \Drupal::entityManager()->getStorage('user_role')->loadMultiple();
|
||||
$roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple();
|
||||
$authenticated_can_access = $roles[RoleInterface::AUTHENTICATED_ID]->hasPermission('access comments');
|
||||
foreach ($roles as $rid => $role) {
|
||||
if ($role->hasPermission('search content') && !$role->hasPermission('access comments')) {
|
||||
|
@ -477,10 +477,10 @@ function comment_node_update_index(EntityInterface $node) {
|
|||
$mode = $field_definition->getSetting('default_mode');
|
||||
$comments_per_page = $field_definition->getSetting('per_page');
|
||||
if ($node->get($field_name)->status) {
|
||||
$comments = \Drupal::entityManager()->getStorage('comment')
|
||||
$comments = \Drupal::entityTypeManager()->getStorage('comment')
|
||||
->loadThread($node, $field_name, $mode, $comments_per_page);
|
||||
if ($comments) {
|
||||
$build[] = \Drupal::entityManager()->getViewBuilder('comment')->viewMultiple($comments);
|
||||
$build[] = \Drupal::entityTypeManager()->getViewBuilder('comment')->viewMultiple($comments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ function comment_views_data_alter(&$data) {
|
|||
];
|
||||
|
||||
// Provide a integration for each entity type except comment.
|
||||
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
if ($entity_type_id == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ class CommentViewsData extends EntityViewsData {
|
|||
unset($data['comment_field_data']['thread']['filter']);
|
||||
unset($data['comment_field_data']['thread']['argument']);
|
||||
|
||||
$entities_types = \Drupal::entityManager()->getDefinitions();
|
||||
$entities_types = \Drupal::entityTypeManager()->getDefinitions();
|
||||
|
||||
// Provide a relationship for each entity type except comment.
|
||||
foreach ($entities_types as $type => $entity_type) {
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace Drupal\comment\Plugin\views\field;
|
|||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\comment\CommentInterface;
|
||||
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\views\Plugin\views\field\NumericField;
|
||||
|
@ -35,6 +37,20 @@ class NodeNewComments extends NumericField {
|
|||
*/
|
||||
protected $database;
|
||||
|
||||
/**
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The entity field manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
|
||||
*/
|
||||
protected $entityFieldManager;
|
||||
|
||||
/**
|
||||
* Constructs a \Drupal\comment\Plugin\views\field\NodeNewComments object.
|
||||
*
|
||||
|
@ -46,18 +62,38 @@ class NodeNewComments extends NumericField {
|
|||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Database\Connection $database
|
||||
* Database Service Object.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager service.
|
||||
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
|
||||
* The entity field manager service.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityTypeManagerInterface $entity_type_manager = NULL, EntityFieldManagerInterface $entity_field_manager = NULL) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->database = $database;
|
||||
if (!$entity_type_manager) {
|
||||
@trigger_error("Not passing the entity type manager to the NodeNewComments constructor is deprecated in drupal:8.8.0 and will be required in drupal 9.0.0. @see https://www.drupal.org/node/3047897");
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
}
|
||||
if (!$entity_field_manager) {
|
||||
@trigger_error("Not passing the entity type manager to the NodeNewComments constructor is deprecated in drupal:8.8.0 and will be required in drupal 9.0.0. @see https://www.drupal.org/node/3047897");
|
||||
$entity_field_manager = \Drupal::service('entity_field.manager');
|
||||
}
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->entityFieldManager = $entity_field_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static($configuration, $plugin_id, $plugin_definition, $container->get('database'));
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('database'),
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('entity_field.manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,8 +202,7 @@ class NodeNewComments extends NumericField {
|
|||
// reference, we arbitrarily use the first such field name we find.
|
||||
// @todo Provide a means for selecting the comment field.
|
||||
// https://www.drupal.org/node/2594201
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
$field_map = \Drupal::service('entity_field.manager')->getFieldMapByFieldType('comment');
|
||||
$field_map = $this->entityFieldManager->getFieldMapByFieldType('comment');
|
||||
$comment_field_name = 'comment';
|
||||
foreach ($field_map['node'] as $field_name => $field_data) {
|
||||
foreach ($field_data['bundles'] as $bundle_name) {
|
||||
|
@ -177,7 +212,7 @@ class NodeNewComments extends NumericField {
|
|||
}
|
||||
}
|
||||
}
|
||||
$page_number = $entity_type_manager->getStorage('comment')
|
||||
$page_number = $this->entityTypeManager->getStorage('comment')
|
||||
->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node, $comment_field_name);
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
$this->options['alter']['url'] = $node->toUrl();
|
||||
|
|
|
@ -176,7 +176,7 @@ abstract class CommentTestBase extends WebTestBase {
|
|||
}
|
||||
|
||||
if (isset($match[1])) {
|
||||
\Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]);
|
||||
\Drupal::entityTypeManager()->getStorage('comment')->resetCache([$match[1]]);
|
||||
return Comment::load($match[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ class CommentPagerTest extends CommentTestBase {
|
|||
|
||||
$node = Node::load($node->id());
|
||||
foreach ($expected_pages as $new_replies => $expected_page) {
|
||||
$returned_page = \Drupal::entityManager()->getStorage('comment')
|
||||
$returned_page = \Drupal::entityTypeManager()->getStorage('comment')
|
||||
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment');
|
||||
$this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page]));
|
||||
}
|
||||
|
@ -305,10 +305,10 @@ class CommentPagerTest extends CommentTestBase {
|
|||
6 => 0,
|
||||
];
|
||||
|
||||
\Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
|
||||
\Drupal::entityTypeManager()->getStorage('node')->resetCache([$node->id()]);
|
||||
$node = Node::load($node->id());
|
||||
foreach ($expected_pages as $new_replies => $expected_page) {
|
||||
$returned_page = \Drupal::entityManager()->getStorage('comment')
|
||||
$returned_page = \Drupal::entityTypeManager()->getStorage('comment')
|
||||
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment');
|
||||
$this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page]));
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ class CommentPreviewTest extends CommentTestBase {
|
|||
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save'));
|
||||
|
||||
// Check that the saved comment is still correct.
|
||||
$comment_storage = \Drupal::entityManager()->getStorage('comment');
|
||||
$comment_storage = \Drupal::entityTypeManager()->getStorage('comment');
|
||||
$comment_storage->resetCache([$comment->id()]);
|
||||
/** @var \Drupal\comment\CommentInterface $comment_loaded */
|
||||
$comment_loaded = Comment::load($comment->id());
|
||||
|
|
|
@ -171,7 +171,7 @@ abstract class CommentTestBase extends BrowserTestBase {
|
|||
}
|
||||
|
||||
if (isset($match[1])) {
|
||||
\Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]);
|
||||
\Drupal::entityTypeManager()->getStorage('comment')->resetCache([$match[1]]);
|
||||
return Comment::load($match[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,8 +125,8 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doTestPublishedStatus() {
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$storage = $entity_manager->getStorage($this->entityTypeId);
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
$storage = $entity_type_manager->getStorage($this->entityTypeId);
|
||||
|
||||
$storage->resetCache();
|
||||
$entity = $storage->load($this->entityId);
|
||||
|
|
|
@ -84,7 +84,7 @@ class CommentTypeTest extends CommentTestBase {
|
|||
// Save the form and ensure the entity-type value is preserved even though
|
||||
// the field isn't present.
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
\Drupal::entityManager()->getStorage('comment_type')->resetCache(['foo']);
|
||||
\Drupal::entityTypeManager()->getStorage('comment_type')->resetCache(['foo']);
|
||||
$comment_type = CommentType::load('foo');
|
||||
$this->assertEqual($comment_type->getTargetEntityTypeId(), 'node');
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
$commented_entity->save();
|
||||
|
||||
// Verify cache tags on the rendered entity before it has comments.
|
||||
$build = \Drupal::entityManager()
|
||||
$build = \Drupal::entityTypeManager()
|
||||
->getViewBuilder('entity_test')
|
||||
->view($commented_entity);
|
||||
$renderer->renderRoot($build);
|
||||
|
@ -117,7 +117,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
$commented_entity = $storage->load($commented_entity->id());
|
||||
|
||||
// Verify cache tags on the rendered entity when it has comments.
|
||||
$build = \Drupal::entityManager()
|
||||
$build = \Drupal::entityTypeManager()
|
||||
->getViewBuilder('entity_test')
|
||||
->view($commented_entity);
|
||||
$renderer->renderRoot($build);
|
||||
|
@ -142,7 +142,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
// builder elements bubble up outside of the entity and we can check that
|
||||
// it got the correct cache max age.
|
||||
$build = ['#type' => 'container'];
|
||||
$build['entity'] = \Drupal::entityManager()
|
||||
$build['entity'] = \Drupal::entityTypeManager()
|
||||
->getViewBuilder('entity_test')
|
||||
->view($commented_entity);
|
||||
$renderer->renderRoot($build);
|
||||
|
|
|
@ -138,7 +138,7 @@ class CommentValidationTest extends EntityKernelTestBase {
|
|||
$field->setSetting('anonymous', CommentInterface::ANONYMOUS_MUST_CONTACT);
|
||||
$field->save();
|
||||
// Reset the node entity.
|
||||
\Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
|
||||
\Drupal::entityTypeManager()->getStorage('node')->resetCache([$node->id()]);
|
||||
$node = Node::load($node->id());
|
||||
// Create a new comment with the new field.
|
||||
$comment = $this->entityTypeManager->getStorage('comment')->create([
|
||||
|
|
|
@ -31,7 +31,7 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase {
|
|||
$this->installSchema('system', ['sequences']);
|
||||
|
||||
// Make sure uid 0 is created (default uid for comments is 0).
|
||||
$storage = \Drupal::entityManager()->getStorage('user');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('user');
|
||||
// Insert a row for the anonymous user.
|
||||
$storage
|
||||
->create([
|
||||
|
|
|
@ -42,7 +42,7 @@ class CommentUserNameTest extends ViewsKernelTestBase {
|
|||
$this->installConfig(['user']);
|
||||
|
||||
// Create an anonymous user.
|
||||
$storage = \Drupal::entityManager()->getStorage('user');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('user');
|
||||
// Insert a row for the anonymous user.
|
||||
$storage
|
||||
->create([
|
||||
|
|
|
@ -25,7 +25,7 @@ class ConfigEntityListMultilingualTest extends BrowserTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Delete the override config_test entity. It is not required by this test.
|
||||
\Drupal::entityManager()->getStorage('config_test')->load('override')->delete();
|
||||
\Drupal::entityTypeManager()->getStorage('config_test')->load('override')->delete();
|
||||
ConfigurableLanguage::createFromLangcode('hu')->save();
|
||||
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
|
|
|
@ -30,7 +30,7 @@ class ConfigEntityListTest extends BrowserTestBase {
|
|||
parent::setUp();
|
||||
// Delete the override config_test entity since it is not required by this
|
||||
// test.
|
||||
\Drupal::entityManager()->getStorage('config_test')->load('override')->delete();
|
||||
\Drupal::entityTypeManager()->getStorage('config_test')->load('override')->delete();
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class ConfigEntityListTest extends BrowserTestBase {
|
|||
* Tests entity list builder methods.
|
||||
*/
|
||||
public function testList() {
|
||||
$controller = \Drupal::entityManager()->getListBuilder('config_test');
|
||||
$controller = \Drupal::entityTypeManager()->getListBuilder('config_test');
|
||||
|
||||
// Test getStorage() method.
|
||||
$this->assertTrue($controller->getStorage() instanceof EntityStorageInterface, 'EntityStorage instance in storage.');
|
||||
|
@ -252,7 +252,7 @@ class ConfigEntityListTest extends BrowserTestBase {
|
|||
public function testPager() {
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
|
||||
|
||||
$storage = \Drupal::entityManager()->getListBuilder('config_test')->getStorage();
|
||||
$storage = \Drupal::service('entity_type.manager')->getListBuilder('config_test')->getStorage();
|
||||
|
||||
// Create 51 test entities.
|
||||
for ($i = 1; $i < 52; $i++) {
|
||||
|
|
|
@ -94,7 +94,7 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase {
|
|||
// configuration in a modules config/install directory.
|
||||
$this->container->get('module_installer')->install(['config_test']);
|
||||
$this->rebuildContainer();
|
||||
$config_test_storage = \Drupal::entityManager()->getStorage('config_test');
|
||||
$config_test_storage = \Drupal::entityTypeManager()->getStorage('config_test');
|
||||
$this->assertEqual($config_test_storage->load('dotted.default')->label(), 'Default install profile override', 'The config_test entity is overridden by the profile optional configuration.');
|
||||
// Test that override of optional configuration does work.
|
||||
$this->assertEqual($config_test_storage->load('override')->label(), 'Override', 'The optional config_test entity is overridden by the profile optional configuration.');
|
||||
|
@ -115,7 +115,7 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase {
|
|||
// that deleted profile configuration is not re-created.
|
||||
$this->container->get('module_installer')->install(['config_other_module_config_test']);
|
||||
$this->rebuildContainer();
|
||||
$config_test_storage = \Drupal::entityManager()->getStorage('config_test');
|
||||
$config_test_storage = \Drupal::entityTypeManager()->getStorage('config_test');
|
||||
$this->assertNull($config_test_storage->load('completely_new'));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class ConfigSingleImportExportTest extends BrowserTestBase {
|
|||
* Tests importing a single configuration file.
|
||||
*/
|
||||
public function testImport() {
|
||||
$storage = \Drupal::entityManager()->getStorage('config_test');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('config_test');
|
||||
$uuid = \Drupal::service('uuid');
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser(['import configuration']));
|
||||
|
@ -254,7 +254,7 @@ EOD;
|
|||
$this->drupalGet('admin/config/development/configuration/single/export/date_format/fallback');
|
||||
$this->assertFieldByXPath('//select[@name="config_name"]//option[@selected="selected"]', t('Fallback date format (fallback)'), 'The fallback date format config entity is selected when specified in the URL.');
|
||||
|
||||
$fallback_date = \Drupal::entityManager()->getStorage('date_format')->load('fallback');
|
||||
$fallback_date = \Drupal::entityTypeManager()->getStorage('date_format')->load('fallback');
|
||||
$yaml_text = $this->xpath('//textarea[@name="export"]')[0]->getValue();
|
||||
$this->assertEqual(Yaml::decode($yaml_text), $fallback_date->toArray(), 'The fallback date format config entity export code is displayed.');
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@
|
|||
* @see \Drupal\config_translation\Routing\RouteSubscriber::routes()
|
||||
*/
|
||||
function hook_config_translation_info(&$info) {
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
$route_provider = \Drupal::service('router.route_provider');
|
||||
|
||||
// If field UI is not enabled, the base routes of the type
|
||||
// "entity.field_config.{$entity_type}_field_edit_form" are not defined.
|
||||
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
||||
// Add fields entity mappers to all fieldable entity types defined.
|
||||
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
$base_route = NULL;
|
||||
try {
|
||||
$base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form');
|
||||
|
|
|
@ -102,13 +102,13 @@ function config_translation_entity_type_alter(array &$entity_types) {
|
|||
* Implements hook_config_translation_info().
|
||||
*/
|
||||
function config_translation_config_translation_info(&$info) {
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
|
||||
// If field UI is not enabled, the base routes of the type
|
||||
// "entity.field_config.{$entity_type}_field_edit_form" are not defined.
|
||||
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
||||
// Add fields entity mappers to all fieldable entity types defined.
|
||||
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
// Make sure entity type has field UI enabled and has a base route.
|
||||
if ($entity_type->get('field_ui_base_route')) {
|
||||
$info[$entity_type_id . '_fields'] = [
|
||||
|
@ -123,7 +123,7 @@ function config_translation_config_translation_info(&$info) {
|
|||
}
|
||||
|
||||
// Discover configuration entities automatically.
|
||||
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
// Determine base path for entities automatically if provided via the
|
||||
// configuration entity.
|
||||
if (
|
||||
|
|
|
@ -107,7 +107,7 @@ class ConfigTranslationOverviewTest extends BrowserTestBase {
|
|||
$this->assertIdentical('Translate', $dropbutton->getText());
|
||||
}
|
||||
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId());
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($test_entity->getEntityTypeId());
|
||||
$this->drupalGet($base_url . '/translate');
|
||||
|
||||
$title = $test_entity->label() . ' ' . $entity_type->getLowercaseLabel();
|
||||
|
|
|
@ -62,8 +62,8 @@ class MessageEntityTest extends EntityKernelTestBase {
|
|||
$access_user = $this->createUser(['uid' => 3], ['access site-wide contact form']);
|
||||
$admin = $this->createUser(['uid' => 4], ['administer contact forms']);
|
||||
|
||||
$this->assertFalse(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $no_access_user));
|
||||
$this->assertTrue(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $access_user));
|
||||
$this->assertFalse(\Drupal::entityTypeManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $no_access_user));
|
||||
$this->assertTrue(\Drupal::entityTypeManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $access_user));
|
||||
$this->assertTrue($message->access('edit', $admin));
|
||||
$this->assertFalse($message->access('edit', $access_user));
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ function content_translation_entity_operation(EntityInterface $entity) {
|
|||
function content_translation_views_data_alter(array &$data) {
|
||||
// Add the content translation entity link definition to Views data for entity
|
||||
// types having translation enabled.
|
||||
$entity_types = \Drupal::entityManager()->getDefinitions();
|
||||
$entity_types = \Drupal::entityTypeManager()->getDefinitions();
|
||||
/** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */
|
||||
$manager = \Drupal::service('content_translation.manager');
|
||||
foreach ($entity_types as $entity_type_id => $entity_type) {
|
||||
|
@ -393,7 +393,7 @@ function content_translation_form_alter(array &$form, FormStateInterface $form_s
|
|||
// be the 'add' or 'edit' form. It also tries a 'default' form in case neither
|
||||
// of the aforementioned forms are defined.
|
||||
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && in_array($op, ['edit', 'add', 'default'], TRUE)) {
|
||||
$controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation');
|
||||
$controller = \Drupal::entityTypeManager()->getHandler($entity->getEntityTypeId(), 'translation');
|
||||
$controller->entityFormAlter($form, $form_state, $entity);
|
||||
|
||||
// @todo Move the following lines to the code generating the property form
|
||||
|
@ -454,7 +454,7 @@ function content_translation_language_fallback_candidates_entity_view_alter(&$ca
|
|||
function content_translation_entity_extra_field_info() {
|
||||
$extra = [];
|
||||
$bundle_info_service = \Drupal::service('entity_type.bundle.info');
|
||||
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $info) {
|
||||
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type => $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'] = [
|
||||
|
|
|
@ -127,7 +127,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
|
|||
* Returns the translate permissions for the current entity and bundle.
|
||||
*/
|
||||
protected function getTranslatePermission() {
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId);
|
||||
if ($permission_granularity = $entity_type->getPermissionGranularity()) {
|
||||
return $permission_granularity == 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}";
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
|
|||
// picked up.
|
||||
\Drupal::service('content_translation.manager')->setEnabled($this->entityTypeId, $this->bundle, TRUE);
|
||||
|
||||
\Drupal::entityManager()->clearCachedDefinitions();
|
||||
\Drupal::entityTypeManager()->clearCachedDefinitions();
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
|
|||
protected function createEntity($values, $langcode, $bundle_name = NULL) {
|
||||
$entity_values = $values;
|
||||
$entity_values['langcode'] = $langcode;
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId);
|
||||
if ($bundle_key = $entity_type->getKey('bundle')) {
|
||||
$entity_values[$bundle_key] = $bundle_name ?: $this->bundle;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ class ContentTranslationOperationsTest extends NodeTestBase {
|
|||
* @see content_translation_translate_access()
|
||||
*/
|
||||
public function testContentTranslationOverviewAccess() {
|
||||
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node');
|
||||
$access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node');
|
||||
$user = $this->createUser(['create content translations', 'access content']);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
|
|||
* Returns the translate permissions for the current entity and bundle.
|
||||
*/
|
||||
protected function getTranslatePermission() {
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId);
|
||||
if ($permission_granularity = $entity_type->getPermissionGranularity()) {
|
||||
return $permission_granularity == 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}";
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
|
|||
protected function createEntity($values, $langcode, $bundle_name = NULL) {
|
||||
$entity_values = $values;
|
||||
$entity_values['langcode'] = $langcode;
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId);
|
||||
if ($bundle_key = $entity_type->getKey('bundle')) {
|
||||
$entity_values[$bundle_key] = $bundle_name ?: $this->bundle;
|
||||
}
|
||||
|
|
|
@ -624,7 +624,7 @@ function editor_filter_format_presave(FilterFormatInterface $format) {
|
|||
}
|
||||
|
||||
/** @var \Drupal\filter\FilterFormatInterface $original */
|
||||
$original = \Drupal::entityManager()
|
||||
$original = \Drupal::entityTypeManager()
|
||||
->getStorage('filter_format')
|
||||
->loadUnchanged($format->getOriginalId());
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class Editor extends ConfigEntityBase implements EditorInterface {
|
|||
*/
|
||||
public function getFilterFormat() {
|
||||
if (!$this->filterFormat) {
|
||||
$this->filterFormat = \Drupal::entityManager()->getStorage('filter_format')->load($this->format);
|
||||
$this->filterFormat = \Drupal::entityTypeManager()->getStorage('filter_format')->load($this->format);
|
||||
}
|
||||
return $this->filterFormat;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class EditorImageDialogTest extends EntityKernelTestBase {
|
|||
->addBuildInfo('args', [$this->editor]);
|
||||
|
||||
$form_builder = $this->container->get('form_builder');
|
||||
$form_object = new EditorImageDialog(\Drupal::entityManager()->getStorage('file'));
|
||||
$form_object = new EditorImageDialog(\Drupal::entityTypeManager()->getStorage('file'));
|
||||
$form_id = $form_builder->getFormId($form_object, $form_state);
|
||||
$form = $form_builder->retrieveForm($form_id, $form_state);
|
||||
$form_builder->prepareForm($form_id, $form, $form_state);
|
||||
|
|
|
@ -171,7 +171,7 @@ function field_cron() {
|
|||
* Implements hook_entity_field_storage_info().
|
||||
*/
|
||||
function field_entity_field_storage_info(EntityTypeInterface $entity_type) {
|
||||
if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
|
||||
if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
|
||||
// Query by filtering on the ID as this is more efficient than filtering
|
||||
// on the entity_type property directly.
|
||||
$ids = \Drupal::entityQuery('field_storage_config')
|
||||
|
@ -192,7 +192,7 @@ function field_entity_field_storage_info(EntityTypeInterface $entity_type) {
|
|||
* Implements hook_entity_bundle_field_info().
|
||||
*/
|
||||
function field_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
|
||||
if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
|
||||
if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
|
||||
// Query by filtering on the ID as this is more efficient than filtering
|
||||
// on the entity_type property directly.
|
||||
$ids = \Drupal::entityQuery('field_config')
|
||||
|
@ -213,7 +213,7 @@ function field_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundl
|
|||
* Implements hook_entity_bundle_delete().
|
||||
*/
|
||||
function field_entity_bundle_delete($entity_type_id, $bundle) {
|
||||
$storage = \Drupal::entityManager()->getStorage('field_config');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('field_config');
|
||||
// Get the fields on the bundle.
|
||||
$fields = $storage->loadByProperties(['entity_type' => $entity_type_id, 'bundle' => $bundle]);
|
||||
// This deletes the data for the field as well as the field themselves. This
|
||||
|
@ -271,7 +271,7 @@ function field_entity_bundle_delete($entity_type_id, $bundle) {
|
|||
*/
|
||||
function _field_create_entity_from_ids($ids) {
|
||||
$id_properties = [];
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($ids->entity_type);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($ids->entity_type);
|
||||
if ($id_key = $entity_type->getKey('id')) {
|
||||
$id_properties[$id_key] = $ids->entity_id;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ function field_purge_batch($batch_size, $field_storage_unique_id = NULL) {
|
|||
|
||||
$fields = $deleted_fields_repository->getFieldDefinitions($field_storage_unique_id);
|
||||
|
||||
$info = \Drupal::entityManager()->getDefinitions();
|
||||
$info = \Drupal::entityTypeManager()->getDefinitions();
|
||||
foreach ($fields as $field) {
|
||||
$entity_type = $field->getTargetEntityTypeId();
|
||||
|
||||
|
@ -89,7 +89,7 @@ function field_purge_batch($batch_size, $field_storage_unique_id = NULL) {
|
|||
continue;
|
||||
}
|
||||
|
||||
$count_purged = \Drupal::entityManager()->getStorage($entity_type)->purgeFieldData($field, $batch_size);
|
||||
$count_purged = \Drupal::entityTypeManager()->getStorage($entity_type)->purgeFieldData($field, $batch_size);
|
||||
if ($count_purged < $batch_size || $count_purged == 0) {
|
||||
// No field data remains for the field, so we can remove it.
|
||||
field_purge_field($field);
|
||||
|
@ -163,7 +163,7 @@ function field_purge_field_storage(FieldStorageDefinitionInterface $field_storag
|
|||
$deleted_fields_repository->removeFieldStorageDefinition($field_storage);
|
||||
|
||||
// Notify the storage layer.
|
||||
\Drupal::entityManager()->getStorage($field_storage->getTargetEntityTypeId())->finalizePurge($field_storage);
|
||||
\Drupal::entityTypeManager()->getStorage($field_storage->getTargetEntityTypeId())->finalizePurge($field_storage);
|
||||
|
||||
// Invoke external hooks after the cache is cleared for API consistency.
|
||||
\Drupal::moduleHandler()->invokeAll('field_purge_field_storage', [$field_storage]);
|
||||
|
|
|
@ -71,7 +71,7 @@ class ConfigImporterFieldPurger {
|
|||
$context['sandbox']['field']['steps_to_delete'] = 0;
|
||||
$fields = static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete'));
|
||||
foreach ($fields as $field) {
|
||||
$row_count = \Drupal::entityManager()->getStorage($field->getTargetEntityTypeId())
|
||||
$row_count = \Drupal::entityTypeManager()->getStorage($field->getTargetEntityTypeId())
|
||||
->countFieldData($field);
|
||||
if ($row_count > 0) {
|
||||
// The number of steps to delete each field is determined by the
|
||||
|
@ -117,7 +117,7 @@ class ConfigImporterFieldPurger {
|
|||
// where the module that provides the field type is also being uninstalled.
|
||||
$field_storage_ids = [];
|
||||
foreach ($deletes as $config_name) {
|
||||
$field_storage_config_prefix = \Drupal::entityManager()->getDefinition('field_storage_config')->getConfigPrefix();
|
||||
$field_storage_config_prefix = \Drupal::entityTypeManager()->getDefinition('field_storage_config')->getConfigPrefix();
|
||||
if (strpos($config_name, $field_storage_config_prefix . '.') === 0) {
|
||||
$field_storage_ids[] = ConfigEntityStorage::getIDFromConfigName($config_name, $field_storage_config_prefix);
|
||||
}
|
||||
|
|
|
@ -147,7 +147,6 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
|||
* In case of failures at the configuration storage level.
|
||||
*/
|
||||
public function preSave(EntityStorageInterface $storage) {
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
|
||||
|
||||
$storage_definition = $this->getFieldStorageDefinition();
|
||||
|
@ -248,7 +247,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
|||
}
|
||||
}
|
||||
if ($storages_to_delete) {
|
||||
\Drupal::entityManager()->getStorage('field_storage_config')->delete($storages_to_delete);
|
||||
\Drupal::entityTypeManager()->getStorage('field_storage_config')->delete($storages_to_delete);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,7 +273,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
|||
*/
|
||||
protected function urlRouteParameters($rel) {
|
||||
$parameters = parent::urlRouteParameters($rel);
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->entity_type);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($this->entity_type);
|
||||
$bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle';
|
||||
$parameters[$bundle_parameter_key] = $this->bundle;
|
||||
return $parameters;
|
||||
|
@ -372,7 +371,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
|||
* name, otherwise NULL.
|
||||
*/
|
||||
public static function loadByName($entity_type_id, $bundle, $field_name) {
|
||||
return \Drupal::entityManager()->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.' . $field_name);
|
||||
return \Drupal::entityTypeManager()->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.' . $field_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
|
|||
$this->addDependencies($definition['class']::calculateStorageDependencies($this));
|
||||
|
||||
// Ensure the field is dependent on the provider of the entity type.
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->entity_type);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($this->entity_type);
|
||||
$this->addDependency('module', $entity_type->getProvider());
|
||||
return $this;
|
||||
}
|
||||
|
@ -389,10 +389,10 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
|
|||
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
|
||||
if ($update) {
|
||||
// Invalidate the render cache for all affected entities.
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
$entity_type = $this->getTargetEntityTypeId();
|
||||
if ($entity_manager->hasHandler($entity_type, 'view_builder')) {
|
||||
$entity_manager->getViewBuilder($entity_type)->resetCache();
|
||||
if ($entity_type_manager->hasHandler($entity_type, 'view_builder')) {
|
||||
$entity_type_manager->getViewBuilder($entity_type)->resetCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
|
|||
* TRUE if the field has data for any entity; FALSE otherwise.
|
||||
*/
|
||||
public function hasData() {
|
||||
return \Drupal::entityManager()->getStorage($this->entity_type)->countFieldData($this, TRUE);
|
||||
return \Drupal::entityTypeManager()->getStorage($this->entity_type)->countFieldData($this, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -806,7 +806,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
|
|||
* otherwise NULL.
|
||||
*/
|
||||
public static function loadByName($entity_type_id, $field_name) {
|
||||
return \Drupal::entityManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name);
|
||||
return \Drupal::entityTypeManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -163,7 +163,7 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
|
|||
// default value deleted.
|
||||
$referenced_entities[0]->delete();
|
||||
// Reload the field since deleting the default value can change the field.
|
||||
\Drupal::entityManager()->getStorage($field->getEntityTypeId())->resetCache([$field->id()]);
|
||||
\Drupal::entityTypeManager()->getStorage($field->getEntityTypeId())->resetCache([$field->id()]);
|
||||
$field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName);
|
||||
$this->assertConfigEntityImport($field);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class EntityReferenceAdminTest extends WebDriverTestBase {
|
|||
$this->assertFieldByName('settings[target_type]', 'node');
|
||||
|
||||
// Check that all entity types can be referenced.
|
||||
$this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityManager()->getDefinitions()));
|
||||
$this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityTypeManager()->getDefinitions()));
|
||||
|
||||
// Second step: 'Field settings' form.
|
||||
$this->drupalPostForm(NULL, [], t('Save field settings'));
|
||||
|
|
|
@ -278,7 +278,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
|
|||
}
|
||||
|
||||
// Check that the two field storages have different tables.
|
||||
$storage = \Drupal::entityManager()->getStorage($this->entityTypeId);
|
||||
$storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId);
|
||||
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
|
||||
$table_mapping = $storage->getTableMapping();
|
||||
$deleted_table_name = $table_mapping->getDedicatedDataTableName($deleted_field_storage, TRUE);
|
||||
|
|
|
@ -213,7 +213,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
|
|||
';
|
||||
$renderer->renderRoot($build[0]);
|
||||
$this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
|
||||
$expected_cache_tags = Cache::mergeTags(\Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags());
|
||||
$expected_cache_tags = Cache::mergeTags(\Drupal::entityTypeManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags());
|
||||
$expected_cache_tags = Cache::mergeTags($expected_cache_tags, FilterFormat::load('full_html')->getCacheTags());
|
||||
$this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', ['@formatter' => $formatter]));
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
|
|||
$entity = EntityTest::create();
|
||||
$entity->field_test_entity_test_string_id->target_id = $this->entityStringId->id();
|
||||
$entity->save();
|
||||
$storage = \Drupal::entityManager()->getStorage('entity_test');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('entity_test');
|
||||
$storage->resetCache();
|
||||
$this->assertEqual($this->entityStringId->id(), $storage->load($entity->id())->field_test_entity_test_string_id->target_id);
|
||||
// Verify that the label for the target ID property definition is correct.
|
||||
|
|
|
@ -343,7 +343,7 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
|
|||
$values_2[1]['value'] = 0;
|
||||
|
||||
// Pretend the form has been built.
|
||||
$form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type, 'default'));
|
||||
$form_state->setFormObject(\Drupal::entityTypeManager()->getFormObject($entity_type, 'default'));
|
||||
\Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state);
|
||||
\Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state);
|
||||
$form_state->setValue($this->fieldTestData->field_name, $values);
|
||||
|
|
|
@ -127,7 +127,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
|
|||
}
|
||||
|
||||
// Check that a single load correctly loads field values for both entities.
|
||||
$controller = \Drupal::entityManager()->getStorage($entity->getEntityTypeId());
|
||||
$controller = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId());
|
||||
$controller->resetCache();
|
||||
$entities = $controller->loadMultiple();
|
||||
foreach ($entities as $index => $entity) {
|
||||
|
|
|
@ -39,9 +39,9 @@ class FieldDataCountTest extends FieldKernelTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('entity_test_rev');
|
||||
$this->storage = \Drupal::entityManager()->getStorage('entity_test');
|
||||
$this->storageRev = \Drupal::entityManager()->getStorage('entity_test_rev');
|
||||
$this->storageUser = \Drupal::entityManager()->getStorage('user');
|
||||
$this->storage = \Drupal::entityTypeManager()->getStorage('entity_test');
|
||||
$this->storageRev = \Drupal::entityTypeManager()->getStorage('entity_test_rev');
|
||||
$this->storageUser = \Drupal::entityTypeManager()->getStorage('user');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ class FieldDataCountTest extends FieldKernelTestBase {
|
|||
$entity->save();
|
||||
}
|
||||
|
||||
$storage = \Drupal::entityManager()->getStorage('entity_test');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('entity_test');
|
||||
if ($storage instanceof SqlContentEntityStorage) {
|
||||
// Count the actual number of rows in the field table.
|
||||
$table_mapping = $storage->getTableMapping();
|
||||
|
|
|
@ -82,19 +82,19 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
|
|||
$this->configImporter()->import();
|
||||
|
||||
// Check that the field storages and fields are gone.
|
||||
\Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id]);
|
||||
\Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache([$field_storage_id]);
|
||||
$field_storage = FieldStorageConfig::load($field_storage_id);
|
||||
$this->assertFalse($field_storage, 'The field storage was deleted.');
|
||||
\Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id_2]);
|
||||
\Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache([$field_storage_id_2]);
|
||||
$field_storage_2 = FieldStorageConfig::load($field_storage_id_2);
|
||||
$this->assertFalse($field_storage_2, 'The second field storage was deleted.');
|
||||
\Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id]);
|
||||
\Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id]);
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertFalse($field, 'The field was deleted.');
|
||||
\Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2a]);
|
||||
\Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2a]);
|
||||
$field_2a = FieldConfig::load($field_id_2a);
|
||||
$this->assertFalse($field_2a, 'The second field on test bundle was deleted.');
|
||||
\Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2b]);
|
||||
\Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2b]);
|
||||
$field_2b = FieldConfig::load($field_id_2b);
|
||||
$this->assertFalse($field_2b, 'The second field on test bundle 2 was deleted.');
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ abstract class FieldKernelTestBase extends KernelTestBase {
|
|||
$this->installConfig(['field', 'system']);
|
||||
|
||||
// Create user 1.
|
||||
$storage = \Drupal::entityManager()->getStorage('user');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('user');
|
||||
$storage
|
||||
->create([
|
||||
'uid' => 1,
|
||||
|
|
|
@ -103,7 +103,7 @@ class TimestampFormatterTest extends KernelTestBase {
|
|||
$data = [];
|
||||
|
||||
// Test standard formats.
|
||||
$date_formats = array_keys(\Drupal::entityManager()->getStorage('date_format')->loadMultiple());
|
||||
$date_formats = array_keys(\Drupal::entityTypeManager()->getStorage('date_format')->loadMultiple());
|
||||
|
||||
foreach ($date_formats as $date_format) {
|
||||
$data[] = ['date_format' => $date_format, 'custom_date_format' => '', 'timezone' => ''];
|
||||
|
|
|
@ -109,7 +109,7 @@ class TranslationTest extends FieldKernelTestBase {
|
|||
public function testTranslatableFieldSaveLoad() {
|
||||
// Enable field translations for nodes.
|
||||
field_test_entity_info_translatable('node', TRUE);
|
||||
$entity_type = \Drupal::entityManager()->getDefinition('node');
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition('node');
|
||||
$this->assertTrue($entity_type->isTranslatable(), 'Nodes are translatable.');
|
||||
|
||||
// Prepare the field translations.
|
||||
|
@ -203,7 +203,7 @@ class TranslationTest extends FieldKernelTestBase {
|
|||
* @see https://www.drupal.org/node/2404739
|
||||
*/
|
||||
public function testFieldAccess() {
|
||||
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->entityType);
|
||||
$access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler($this->entityType);
|
||||
$this->assertTrue($access_control_handler->fieldAccess('view', $this->field));
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ function field_ui_entity_operation(EntityInterface $entity) {
|
|||
$info = $entity->getEntityType();
|
||||
// Add manage fields and display links if this entity type is the bundle
|
||||
// of another and that type has field UI enabled.
|
||||
if (($bundle_of = $info->getBundleOf()) && \Drupal::entityManager()->getDefinition($bundle_of)->get('field_ui_base_route')) {
|
||||
if (($bundle_of = $info->getBundleOf()) && \Drupal::entityTypeManager()->getDefinition($bundle_of)->get('field_ui_base_route')) {
|
||||
$account = \Drupal::currentUser();
|
||||
if ($account->hasPermission('administer ' . $bundle_of . ' fields')) {
|
||||
$operations['manage-fields'] = [
|
||||
|
|
|
@ -23,7 +23,7 @@ class FieldUI {
|
|||
* A URL object.
|
||||
*/
|
||||
public static function getOverviewRouteInfo($entity_type_id, $bundle) {
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
|
||||
if ($entity_type->get('field_ui_base_route')) {
|
||||
return new Url("entity.{$entity_type_id}.field_ui_fields", static::getRouteBundleParameter($entity_type, $bundle));
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ function file_field_widget_info_alter(array &$info) {
|
|||
function file_load_multiple(array $fids = NULL, $reset = FALSE) {
|
||||
@trigger_error('file_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\file\Entity\File::loadMultiple(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED);
|
||||
if ($reset) {
|
||||
\Drupal::entityManager()->getStorage('file')->resetCache($fids);
|
||||
\Drupal::entityTypeManager()->getStorage('file')->resetCache($fids);
|
||||
}
|
||||
return File::loadMultiple($fids);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ function file_load_multiple(array $fids = NULL, $reset = FALSE) {
|
|||
function file_load($fid, $reset = FALSE) {
|
||||
@trigger_error('file_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\file\Entity\File::load(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED);
|
||||
if ($reset) {
|
||||
\Drupal::entityManager()->getStorage('file')->resetCache([$fid]);
|
||||
\Drupal::entityTypeManager()->getStorage('file')->resetCache([$fid]);
|
||||
}
|
||||
return File::load($fid);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ function file_validate_size(FileInterface $file, $file_limit = 0, $user_limit =
|
|||
}
|
||||
|
||||
// Save a query by only calling spaceUsed() when a limit is provided.
|
||||
if ($user_limit && (\Drupal::entityManager()->getStorage('file')->spaceUsed($user->id()) + $file->getSize()) > $user_limit) {
|
||||
if ($user_limit && (\Drupal::entityTypeManager()->getStorage('file')->spaceUsed($user->id()) + $file->getSize()) > $user_limit) {
|
||||
$errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', ['%filesize' => format_size($file->getSize()), '%quota' => format_size($user_limit)]);
|
||||
}
|
||||
|
||||
|
@ -714,7 +714,7 @@ function file_file_download($uri) {
|
|||
*/
|
||||
function file_cron() {
|
||||
$age = \Drupal::config('system.file')->get('temporary_maximum_age');
|
||||
$file_storage = \Drupal::entityManager()->getStorage('file');
|
||||
$file_storage = \Drupal::entityTypeManager()->getStorage('file');
|
||||
|
||||
// Only delete temporary files if older than $age. Note that automatic cleanup
|
||||
// is disabled if $age set to 0.
|
||||
|
|
|
@ -38,7 +38,7 @@ function file_field_views_data(FieldStorageConfigInterface $field_storage) {
|
|||
*/
|
||||
function file_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
|
||||
$entity_type_id = $field_storage->getTargetEntityTypeId();
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$entity_manager = \Drupal::entityTypeManager();
|
||||
$entity_type = $entity_manager->getDefinition($entity_type_id);
|
||||
$field_name = $field_storage->getName();
|
||||
$pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id;
|
||||
|
|
|
@ -60,7 +60,7 @@ class FileFieldItemList extends EntityReferenceFieldItemList {
|
|||
|
||||
// Decrement file usage by 1 for files that were removed from the field.
|
||||
$removed_ids = array_filter(array_diff($original_ids, $ids));
|
||||
$removed_files = \Drupal::entityManager()->getStorage('file')->loadMultiple($removed_ids);
|
||||
$removed_files = \Drupal::entityTypeManager()->getStorage('file')->loadMultiple($removed_ids);
|
||||
foreach ($removed_files as $file) {
|
||||
\Drupal::service('file.usage')->delete($file, 'file', $entity->getEntityTypeId(), $entity->id());
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
|
|||
$this->drupalPostForm(NULL, $edit, t('Upload'));
|
||||
|
||||
$fid = $this->getLastFileId();
|
||||
$file = \Drupal::entityManager()->getStorage('file')->load($fid);
|
||||
$file = \Drupal::entityTypeManager()->getStorage('file')->load($fid);
|
||||
$file->delete();
|
||||
|
||||
$this->drupalPostForm(NULL, $edit, t('Upload'));
|
||||
|
|
|
@ -46,7 +46,7 @@ class FilePrivateTest extends FileFieldTestBase {
|
|||
|
||||
$test_file = $this->getTestFile('text');
|
||||
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name, TRUE, ['private' => TRUE]);
|
||||
\Drupal::entityManager()->getStorage('node')->resetCache([$nid]);
|
||||
\Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]);
|
||||
/* @var \Drupal\node\NodeInterface $node */
|
||||
$node = $node_storage->load($nid);
|
||||
$node_file = File::load($node->{$field_name}->target_id);
|
||||
|
@ -67,7 +67,7 @@ class FilePrivateTest extends FileFieldTestBase {
|
|||
// Test with the field that should deny access through field access.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, ['private' => TRUE]);
|
||||
\Drupal::entityManager()->getStorage('node')->resetCache([$nid]);
|
||||
\Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]);
|
||||
$node = $node_storage->load($nid);
|
||||
$node_file = File::load($node->{$no_access_field_name}->target_id);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
|
|||
$this->rebuildContainer();
|
||||
|
||||
// Ensure the file can be downloaded.
|
||||
\Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]);
|
||||
\Drupal::entityTypeManager()->getStorage('node')->resetCache([$default_language_node->id()]);
|
||||
$node = Node::load($default_language_node->id());
|
||||
$node_file = File::load($node->{$this->fieldName}->target_id);
|
||||
$this->drupalGet(file_create_url($node_file->getFileUri()));
|
||||
|
@ -109,7 +109,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
|
|||
$last_fid = $this->getLastFileId();
|
||||
|
||||
// Verify the translation was created.
|
||||
\Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]);
|
||||
\Drupal::entityTypeManager()->getStorage('node')->resetCache([$default_language_node->id()]);
|
||||
$default_language_node = Node::load($default_language_node->id());
|
||||
$this->assertTrue($default_language_node->hasTranslation('fr'), 'Node found in database.');
|
||||
$this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.');
|
||||
|
|
|
@ -103,9 +103,9 @@ function filter_formats(AccountInterface $account = NULL) {
|
|||
$formats['all'] = $cache->data;
|
||||
}
|
||||
else {
|
||||
$formats['all'] = \Drupal::entityManager()->getStorage('filter_format')->loadByProperties(['status' => TRUE]);
|
||||
$formats['all'] = \Drupal::entityTypeManager()->getStorage('filter_format')->loadByProperties(['status' => TRUE]);
|
||||
uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort');
|
||||
\Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, \Drupal::entityManager()->getDefinition('filter_format')->getListCacheTags());
|
||||
\Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, \Drupal::entityTypeManager()->getDefinition('filter_format')->getListCacheTags());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ class FilterAPITest extends EntityKernelTestBase {
|
|||
$this->assertTrue(isset($filters['filter_test_restrict_tags_and_attributes']), 'The filter plugin filter_test_restrict_tags_and_attributes is configured by the filtered_html filter format.');
|
||||
|
||||
drupal_static_reset('filter_formats');
|
||||
\Drupal::entityManager()->getStorage('filter_format')->resetCache();
|
||||
\Drupal::entityTypeManager()->getStorage('filter_format')->resetCache();
|
||||
$module_data = \Drupal::service('extension.list.module')->reset()->getList();
|
||||
$this->assertFalse(isset($module_data['filter_test']->info['required']), 'The filter_test module is required.');
|
||||
|
||||
|
@ -500,7 +500,7 @@ class FilterAPITest extends EntityKernelTestBase {
|
|||
|
||||
// Verify the filter format still exists but the dependency and filter is
|
||||
// gone.
|
||||
\Drupal::entityManager()->getStorage('filter_format')->resetCache();
|
||||
\Drupal::entityTypeManager()->getStorage('filter_format')->resetCache();
|
||||
$filter_format = FilterFormat::load('filtered_html');
|
||||
$this->assertEqual([], $filter_format->getDependencies());
|
||||
// Use the get method since the FilterFormat::filters() method only returns
|
||||
|
|
|
@ -472,7 +472,7 @@ function template_preprocess_forums(&$variables) {
|
|||
$variables['topics'][$id]->new_url = '';
|
||||
|
||||
if ($topic->new_replies) {
|
||||
$page_number = \Drupal::entityManager()->getStorage('comment')
|
||||
$page_number = \Drupal::entityTypeManager()->getStorage('comment')
|
||||
->getNewCommentPageNumber($topic->comment_count, $topic->new_replies, $topic, 'comment_forum');
|
||||
$query = $page_number ? ['page' => $page_number] : NULL;
|
||||
$variables['topics'][$id]->new_text = \Drupal::translation()->formatPlural($topic->new_replies, '1 new post<span class="visually-hidden"> in topic %title</span>', '@count new posts<span class="visually-hidden"> in topic %title</span>', ['%title' => $variables['topics'][$id]->label()]);
|
||||
|
|
|
@ -39,11 +39,11 @@ function image_field_views_data(FieldStorageConfigInterface $field_storage) {
|
|||
function image_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
|
||||
$entity_type_id = $field_storage->getTargetEntityTypeId();
|
||||
$field_name = $field_storage->getName();
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$entity_type = $entity_manager->getDefinition($entity_type_id);
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
$entity_type = $entity_type_manager->getDefinition($entity_type_id);
|
||||
$pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id;
|
||||
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
|
||||
$table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping();
|
||||
$table_mapping = $entity_type_manager->getStorage($entity_type_id)->getTableMapping();
|
||||
|
||||
list($label) = views_entity_field_label($entity_type_id, $field_name);
|
||||
|
||||
|
|
|
@ -481,7 +481,7 @@ class ImageItem extends FileItem {
|
|||
if (isset($element['fids']['#value'][0])) {
|
||||
$value = $element['fids']['#value'][0];
|
||||
// Convert the file ID to a uuid.
|
||||
if ($file = \Drupal::entityManager()->getStorage('file')->load($value)) {
|
||||
if ($file = \Drupal::entityTypeManager()->getStorage('file')->load($value)) {
|
||||
$value = $file->uuid();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ class ImageWidget extends FileWidget {
|
|||
if ($style_id && $style = ImageStyle::load($style_id)) {
|
||||
if (!empty($dependencies[$style->getConfigDependencyKey()][$style->getConfigDependencyName()])) {
|
||||
/** @var \Drupal\image\ImageStyleStorageInterface $storage */
|
||||
$storage = \Drupal::entityManager()->getStorage($style->getEntityTypeId());
|
||||
$storage = \Drupal::entityTypeManager()->getStorage($style->getEntityTypeId());
|
||||
$replacement_id = $storage->getReplacementId($style_id);
|
||||
// If a valid replacement has been provided in the storage, replace the
|
||||
// preview image style with the replacement.
|
||||
|
|
|
@ -748,7 +748,7 @@ class JsonApiFunctionalTest extends JsonApiFunctionalTestBase {
|
|||
$this->assertEquals("The current user is not allowed to PATCH the selected field (status). The 'administer nodes' permission is required.",
|
||||
$updated_response['errors'][0]['detail']);
|
||||
|
||||
$node = \Drupal::entityManager()->loadEntityByUuid('node', $uuid);
|
||||
$node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid);
|
||||
$this->assertEquals(1, $node->get('status')->value, 'Node status was not changed.');
|
||||
// 9. Successful POST to related endpoint.
|
||||
$body = [
|
||||
|
|
|
@ -330,7 +330,7 @@ function language_modules_installed($modules) {
|
|||
// this is not a hard dependency, and thus is not detected by the config
|
||||
// system, we have to clean up the related values manually.
|
||||
foreach (['entity_view_display', 'entity_form_display'] as $key) {
|
||||
$displays = \Drupal::entityManager()->getStorage($key)->loadMultiple();
|
||||
$displays = \Drupal::entityTypeManager()->getStorage($key)->loadMultiple();
|
||||
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
|
||||
foreach ($displays as $display) {
|
||||
$display->save();
|
||||
|
|
|
@ -190,7 +190,7 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag
|
|||
if ($entity_type_id == NULL || $bundle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
$config = \Drupal::entityManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle);
|
||||
$config = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle);
|
||||
if ($config == NULL) {
|
||||
$config = ContentLanguageSettings::create(['target_entity_type_id' => $entity_type_id, 'target_bundle' => $bundle]);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag
|
|||
parent::calculateDependencies();
|
||||
|
||||
// Create dependency on the bundle.
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->target_entity_type_id);
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($this->target_entity_type_id);
|
||||
$bundle_config_dependency = $entity_type->getBundleConfigDependency($this->target_bundle);
|
||||
$this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']);
|
||||
|
||||
|
|
|
@ -203,15 +203,15 @@ class LanguageConfigurationElementTest extends BrowserTestBase {
|
|||
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
|
||||
|
||||
// Check the language default configuration for articles is present.
|
||||
$configuration = \Drupal::entityManager()->getStorage('language_content_settings')->load('node.article');
|
||||
$configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load('node.article');
|
||||
$this->assertTrue($configuration, 'The language configuration is present.');
|
||||
|
||||
// Delete 'article' bundle.
|
||||
$this->drupalPostForm('admin/structure/types/manage/article/delete', [], t('Delete'));
|
||||
|
||||
// Check that the language configuration has been deleted.
|
||||
\Drupal::entityManager()->getStorage('language_content_settings')->resetCache();
|
||||
$configuration = \Drupal::entityManager()->getStorage('language_content_settings')->load('node.article');
|
||||
\Drupal::entityTypeManager()->getStorage('language_content_settings')->resetCache();
|
||||
$configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load('node.article');
|
||||
$this->assertFalse($configuration, 'The language configuration was deleted after bundle was deleted.');
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ function menu_link_content_entity_type_alter(array &$entity_types) {
|
|||
* Implements hook_menu_delete().
|
||||
*/
|
||||
function menu_link_content_menu_delete(MenuInterface $menu) {
|
||||
$storage = \Drupal::entityManager()->getStorage('menu_link_content');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('menu_link_content');
|
||||
$menu_links = $storage->loadByProperties(['menu_name' => $menu->id()]);
|
||||
$storage->delete($menu_links);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ function _menu_link_content_update_path_alias($path) {
|
|||
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
|
||||
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
|
||||
/** @var \Drupal\menu_link_content\MenuLinkContentInterface[] $entities */
|
||||
$entities = \Drupal::entityManager()
|
||||
$entities = \Drupal::entityTypeManager()
|
||||
->getStorage('menu_link_content')
|
||||
->loadByProperties(['link.uri' => 'internal:' . $path]);
|
||||
foreach ($entities as $menu_link) {
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class MenuWebTestBase extends WebTestBase {
|
|||
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
|
||||
$menu_link_manager->resetDefinitions();
|
||||
// Reset the static load cache.
|
||||
\Drupal::entityManager()->getStorage('menu_link_content')->resetCache();
|
||||
\Drupal::entityTypeManager()->getStorage('menu_link_content')->resetCache();
|
||||
$definition = $menu_link_manager->getDefinition($menu_plugin_id);
|
||||
|
||||
$entity = NULL;
|
||||
|
@ -46,7 +46,7 @@ abstract class MenuWebTestBase extends WebTestBase {
|
|||
if (strpos($menu_plugin_id, 'menu_link_content') === 0) {
|
||||
list(, $uuid) = explode(':', $menu_plugin_id, 2);
|
||||
/** @var \Drupal\menu_link_content\Entity\MenuLinkContent $entity */
|
||||
$entity = \Drupal::entityManager()->loadEntityByUuid('menu_link_content', $uuid);
|
||||
$entity = \Drupal::service('entity.repository')->loadEntityByUuid('menu_link_content', $uuid);
|
||||
}
|
||||
|
||||
if (isset($expected_item['children'])) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue