only in patch2: unchanged: --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -121,15 +121,18 @@ public function addBodyField($comment_type_id) { )); $field->save(); - // Assign widget settings for the 'default' form mode. - entity_get_form_display('comment', $comment_type_id, 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = \Drupal::service('entity_display.repository'); + + // Assign widget settings for the default form mode. + $display_repository->getFormDisplay('comment', $comment_type_id) ->setComponent('comment_body', array( 'type' => 'text_textarea', )) ->save(); - // Assign display settings for the 'default' view mode. - entity_get_display('comment', $comment_type_id, 'default') + // Assign display settings for the default view mode. + $display_repository->getViewDisplay('comment', $comment_type_id) ->setComponent('comment_body', array( 'label' => 'hidden', 'type' => 'text_default', only in patch2: unchanged: --- a/core/modules/comment/src/Tests/CommentLinksTest.php +++ b/core/modules/comment/src/Tests/CommentLinksTest.php @@ -101,8 +101,11 @@ public function testCommentLinks() { $this->assertLink('Add new comment'); } + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Change weight to make links go before comment body. - entity_get_display('comment', 'comment', 'default') + $display_repository->getViewDisplay('comment', 'comment') ->setComponent('links', array('weight' => -100)) ->save(); $this->drupalGet($this->node->urlInfo()); @@ -112,7 +115,7 @@ public function testCommentLinks() { $this->assertIdentical($element[0]->getName(), 'div', 'Last element is comment body.'); // Change weight to make links go after comment body. - entity_get_display('comment', 'comment', 'default') + $display_repository->getViewDisplay('comment', 'comment') ->setComponent('links', array('weight' => 100)) ->save(); $this->drupalGet($this->node->urlInfo()); @@ -122,7 +125,7 @@ public function testCommentLinks() { $this->assertIdentical($element[0]->getName(), 'ul', 'Last element is comment links.'); // Make sure we can hide node links. - entity_get_display('node', $this->node->bundle(), 'default') + $display_repository->getViewDisplay('node', $this->node->bundle()) ->removeComponent('links') ->save(); $this->drupalGet($this->node->urlInfo()); @@ -135,7 +138,7 @@ public function testCommentLinks() { $this->assertLink('Reply'); // Make sure we can hide comment links. - entity_get_display('comment', 'comment', 'default') + $display_repository->getViewDisplay('comment', 'comment') ->removeComponent('links') ->save(); $this->drupalGet('node/' . $this->node->id()); only in patch2: unchanged: --- a/core/modules/config/src/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php @@ -115,18 +115,20 @@ public function testExportImport() { ])->save(); // Update the displays so that configuration does not change unexpectedly on // import. - entity_get_form_display('node', $this->contentType->id(), 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + $display_repository->getFormDisplay('node', $this->contentType->id()) ->setComponent($this->fieldName, array( 'type' => 'text_textfield', )) ->save(); - entity_get_display('node', $this->contentType->id(), 'full') + $display_repository->getViewDisplay('node', $this->contentType->id(), 'full') ->setComponent($this->fieldName) ->save(); - entity_get_display('node', $this->contentType->id(), 'default') + $display_repository->getViewDisplay('node', $this->contentType->id()) ->setComponent($this->fieldName) ->save(); - entity_get_display('node', $this->contentType->id(), 'teaser') + $display_repository->getViewDisplay('node', $this->contentType->id(), 'teaser') ->removeComponent($this->fieldName) ->save(); only in patch2: unchanged: --- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php @@ -97,11 +97,16 @@ function testDateField() { // the default time, so that is applied before calculating the expected // value. datetime_date_default_time($date); + + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + foreach ($options as $setting => $values) { foreach ($values as $new_value) { // Update the entity display settings. $this->displayOptions['settings'] = array($setting => $new_value) + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -122,7 +127,7 @@ function testDateField() { // Verify that the plain formatter works. $this->displayOptions['type'] = 'datetime_plain'; $this->displayOptions['settings'] = $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format(DATETIME_DATE_STORAGE_FORMAT); @@ -132,7 +137,7 @@ function testDateField() { // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'datetime_custom'; $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format']); @@ -157,7 +162,7 @@ function testDateField() { 'past_format' => '@interval in the past', 'granularity' => 3, ); - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = SafeMarkup::format($this->displayOptions['settings']['past_format'], [ @@ -178,7 +183,7 @@ function testDateField() { $entity->{$field_name}->value = $date->format($date_format); $entity->save(); - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = SafeMarkup::format($this->displayOptions['settings']['future_format'], [ @@ -225,6 +230,9 @@ function testDatetimeField() { $this->assertRaw($date->format($date_format)); $this->assertRaw($date->format($time_format)); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Verify that the date is output according to the formatter settings. $options = array( 'format_type' => array('short', 'medium', 'long'), @@ -233,7 +241,7 @@ function testDatetimeField() { foreach ($values as $new_value) { // Update the entity display settings. $this->displayOptions['settings'] = array($setting => $new_value) + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -253,7 +261,7 @@ function testDatetimeField() { // Verify that the plain formatter works. $this->displayOptions['type'] = 'datetime_plain'; $this->displayOptions['settings'] = $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format(DATETIME_DATETIME_STORAGE_FORMAT); @@ -263,7 +271,7 @@ function testDatetimeField() { // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'datetime_custom'; $this->displayOptions['settings'] = array('date_format' => 'm/d/Y g:i:s A') + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format']); @@ -273,7 +281,7 @@ function testDatetimeField() { // Verify that the 'timezone_override' setting works. $this->displayOptions['type'] = 'datetime_custom'; $this->displayOptions['settings'] = array('date_format' => 'm/d/Y g:i:s A', 'timezone_override' => 'America/New_York') + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format'], array('timezone' => 'America/New_York')); @@ -298,7 +306,7 @@ function testDatetimeField() { 'past_format' => '@interval earlier', 'granularity' => 3, ); - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = SafeMarkup::format($this->displayOptions['settings']['past_format'], [ @@ -319,7 +327,7 @@ function testDatetimeField() { $entity->{$field_name}->value = $date->format(DATETIME_DATETIME_STORAGE_FORMAT); $entity->save(); - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = SafeMarkup::format($this->displayOptions['settings']['future_format'], [ only in patch2: unchanged: --- a/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php +++ b/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php @@ -118,8 +118,11 @@ public function testDateRangeField() { ] + $this->defaultSettings, ]; + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Verify that the default formatter works. - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -148,7 +151,7 @@ public function testDateRangeField() { // Verify that the plain formatter works. $this->displayOptions['type'] = 'daterange_plain'; $this->displayOptions['settings'] = $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATE_STORAGE_FORMAT); @@ -158,7 +161,7 @@ public function testDateRangeField() { // Verify that the custom formatter works. $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']); @@ -194,7 +197,7 @@ public function testDateRangeField() { ] + $this->defaultSettings, ]; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -215,7 +218,7 @@ public function testDateRangeField() { $this->displayOptions['type'] = 'daterange_plain'; $this->displayOptions['settings'] = $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT); @@ -225,7 +228,7 @@ public function testDateRangeField() { $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']); @@ -281,12 +284,15 @@ public function testDatetimeRangeField() { $this->assertRaw($end_date->format($date_format)); $this->assertRaw($end_date->format($time_format)); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Verify that the default formatter works. $this->displayOptions['settings'] = [ 'format_type' => 'long', 'separator' => 'THESEPARATOR', ] + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -307,7 +313,7 @@ public function testDatetimeRangeField() { // Verify that the plain formatter works. $this->displayOptions['type'] = 'daterange_plain'; $this->displayOptions['settings'] = $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT); @@ -317,7 +323,7 @@ public function testDatetimeRangeField() { // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A'] + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']); @@ -327,7 +333,7 @@ public function testDatetimeRangeField() { // Verify that the 'timezone_override' setting works. $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A', 'timezone_override' => 'America/New_York'] + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); @@ -365,7 +371,7 @@ public function testDatetimeRangeField() { ] + $this->defaultSettings, ]; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -382,7 +388,7 @@ public function testDatetimeRangeField() { $this->displayOptions['type'] = 'daterange_plain'; $this->displayOptions['settings'] = $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT); @@ -392,7 +398,7 @@ public function testDatetimeRangeField() { $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A'] + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']); @@ -442,12 +448,15 @@ public function testAlldayRangeField() { $this->assertRaw($end_date->format($date_format)); $this->assertNoRaw($end_date->format($time_format)); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Verify that the default formatter works. $this->displayOptions['settings'] = [ 'format_type' => 'long', 'separator' => 'THESEPARATOR', ] + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -468,7 +477,7 @@ public function testAlldayRangeField() { // Verify that the plain formatter works. $this->displayOptions['type'] = 'daterange_plain'; $this->displayOptions['settings'] = $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT); @@ -478,7 +487,7 @@ public function testAlldayRangeField() { // Verify that the custom formatter works. $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']); @@ -488,7 +497,7 @@ public function testAlldayRangeField() { // Verify that the 'timezone_override' setting works. $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A', 'timezone_override' => 'America/New_York'] + $this->defaultSettings; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); @@ -525,7 +534,7 @@ public function testAlldayRangeField() { ] + $this->defaultSettings, ]; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -544,7 +553,7 @@ public function testAlldayRangeField() { $this->assertFieldByXPath('//div[@data-field-item-attr="foobar"]'); $this->displayOptions['type'] = 'daterange_plain'; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' THESEPARATOR ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT); @@ -554,7 +563,7 @@ public function testAlldayRangeField() { $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings']['date_format'] = 'm/d/Y'; - entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') + $display_repository->getViewDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' THESEPARATOR ' . $end_date->format($this->displayOptions['settings']['date_format']); only in patch2: unchanged: --- a/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php +++ b/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php @@ -125,7 +125,9 @@ protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'defa $storage->resetCache([$entity_id]); $entity = $storage->load($entity_id); $items = $entity->get($field_name); - $options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name); + $options = $this->container->get('entity_display.repository') + ->getViewDisplay('entity_test', 'entity_test', $view_mode) + ->getComponent($field_name); return $this->editorSelector->getEditor($options['type'], $items); } only in patch2: unchanged: --- a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php @@ -84,14 +84,17 @@ function testBooleanField() { )); $this->field->save(); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Create a form display for the default form mode. - entity_get_form_display('entity_test', 'entity_test', 'default') + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'boolean_checkbox', )) ->save(); // Create a display for the full view mode. - entity_get_display('entity_test', 'entity_test', 'full') + $display_repository->getViewDisplay('entity_test', 'entity_test', 'full') ->setComponent($field_name, array( 'type' => 'boolean', )) @@ -114,13 +117,13 @@ function testBooleanField() { // Verify that boolean value is displayed. $entity = EntityTest::load($id); - $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); + $display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full'); $content = $display->build($entity); $this->setRawContent(\Drupal::service('renderer')->renderRoot($content)); $this->assertRaw('
' . $on . '
'); // Test with "On" label option. - entity_get_form_display('entity_test', 'entity_test', 'default') + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'boolean_checkbox', 'settings' => array( @@ -210,15 +213,18 @@ public function testFormAccess() { ]); $this->field->save(); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Create a form display for the default form mode. - entity_get_form_display('entity_test', 'entity_test', 'default') + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, [ 'type' => 'boolean_checkbox', ]) ->save(); // Create a display for the full view mode. - entity_get_display('entity_test', 'entity_test', 'full') + $display_repository->getViewDisplay('entity_test', 'entity_test', 'full') ->setComponent($field_name, [ 'type' => 'boolean', ]) only in patch2: unchanged: --- a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php @@ -66,12 +66,13 @@ protected function setUp() { ]); $instance->save(); - $display = entity_get_display('node', $this->bundle, 'default') + $this->container->get('entity_display.repository') + ->getViewDisplay('node', $this->bundle) ->setComponent($this->fieldName, [ 'type' => 'boolean', 'settings' => [], - ]); - $display->save(); + ]) + ->save(); } /** only in patch2: unchanged: --- a/core/modules/field/src/Tests/Email/EmailFieldTest.php +++ b/core/modules/field/src/Tests/Email/EmailFieldTest.php @@ -64,8 +64,11 @@ function testEmailField() { ]); $this->field->save(); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + // Create a form display for the default form mode. - entity_get_form_display('entity_test', 'entity_test', 'default') + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'email_default', 'settings' => array( @@ -74,7 +77,7 @@ function testEmailField() { )) ->save(); // Create a display for the full view mode. - entity_get_display('entity_test', 'entity_test', 'full') + $display_repository->getViewDisplay('entity_test', 'entity_test', 'full') ->setComponent($field_name, array( 'type' => 'email_mailto', )) @@ -98,7 +101,7 @@ function testEmailField() { // Verify that a mailto link is displayed. $entity = EntityTest::load($id); - $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); + $display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full'); $content = $display->build($entity); $this->setRawContent(\Drupal::service('renderer')->renderRoot($content)); $this->assertLinkByHref('mailto:test@example.com'); only in patch2: unchanged: --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceAutoCreateTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceAutoCreateTest.php @@ -75,10 +75,13 @@ protected function setUp() { ), ])->save(); - entity_get_display('node', $referencing->id(), 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getViewDisplay('node', $referencing->id()) ->setComponent('test_field') ->save(); - entity_get_form_display('node', $referencing->id(), 'default') + $display_repository->getFormDisplay('node', $referencing->id(), 'default') ->setComponent('test_field', array( 'type' => 'entity_reference_autocomplete', )) only in patch2: unchanged: --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php @@ -224,12 +224,16 @@ protected function setUpEntityReferenceField() { 'entity_type' => $this->testEntityTypeName, ]) ->save(); - entity_get_form_display($this->testEntityTypeName, $this->referrerType->id(), 'default') + + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getFormDisplay($this->testEntityTypeName, $this->referrerType->id()) ->setComponent($this->referenceFieldName, array( 'type' => 'entity_reference_autocomplete', )) ->save(); - entity_get_display($this->testEntityTypeName, $this->referrerType->id(), 'default') + $display_repository->getViewDisplay($this->testEntityTypeName, $this->referrerType->id()) ->setComponent($this->referenceFieldName, array( 'type' => 'entity_reference_label', )) only in patch2: unchanged: --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php @@ -93,11 +93,14 @@ protected function setUp() { 'label' => $this->randomMachineName() . '_label', ])->save(); - entity_get_display('node', $referencing->id(), 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getViewDisplay('node', $referencing->id()) ->setComponent('test_field') ->setComponent($file_field_name) ->save(); - entity_get_form_display('node', $referencing->id(), 'default') + $display_repository->getFormDisplay('node', $referencing->id()) ->setComponent('test_field', array( 'type' => 'entity_reference_autocomplete', )) only in patch2: unchanged: --- a/core/modules/field/src/Tests/FieldAccessTest.php +++ b/core/modules/field/src/Tests/FieldAccessTest.php @@ -58,7 +58,8 @@ protected function setUp() { // Assign display properties for the 'default' and 'teaser' view modes. foreach (array('default', 'teaser') as $view_mode) { - entity_get_display('node', $content_type, $view_mode) + $this->container->get('entity_display.repository') + ->getViewDisplay('node', $content_type, $view_mode) ->setComponent($field_storage['field_name']) ->save(); } only in patch2: unchanged: --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -55,7 +55,10 @@ function testNumberDecimalField() { 'bundle' => 'entity_test', ])->save(); - entity_get_form_display('entity_test', 'entity_test', 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'number', 'settings' => array( @@ -63,7 +66,7 @@ function testNumberDecimalField() { ), )) ->save(); - entity_get_display('entity_test', 'entity_test', 'default') + $display_repository->getViewDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'number_decimal', )) @@ -147,7 +150,10 @@ function testNumberIntegerField() { ) ])->save(); - entity_get_form_display('entity_test', 'entity_test', 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'number', 'settings' => array( @@ -155,7 +161,7 @@ function testNumberIntegerField() { ), )) ->save(); - entity_get_display('entity_test', 'entity_test', 'default') + $display_repository->getViewDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'number_integer', 'settings' => array( @@ -247,7 +253,7 @@ function testNumberIntegerField() { } // Test for the content attribute when a Prefix is displayed. Presumably this also tests for the attribute when a Suffix is displayed. - entity_get_display('entity_test', 'entity_test', 'default') + $display_repository->getViewDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'number_integer', 'settings' => array( @@ -286,7 +292,10 @@ function testNumberFloatField() { 'bundle' => 'entity_test', ])->save(); - entity_get_form_display('entity_test', 'entity_test', 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'number', 'settings' => array( @@ -295,7 +304,7 @@ function testNumberFloatField() { )) ->save(); - entity_get_display('entity_test', 'entity_test', 'default') + $display_repository->getViewDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => 'number_decimal', )) @@ -407,7 +416,10 @@ function testNumberFormatter() { ), ])->save(); - entity_get_form_display('node', $type, 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getFormDisplay('node', $type) ->setComponent($float_field, array( 'type' => 'number', 'settings' => array( @@ -422,7 +434,7 @@ function testNumberFormatter() { )) ->save(); - entity_get_display('node', $type, 'default') + $display_repository->getViewDisplay('node', $type) ->setComponent($float_field, array( 'type' => 'number_decimal', )) @@ -465,7 +477,7 @@ function testNumberFormatter() { $this->assertRaw((string) $random_integer); // Configure the number_decimal formatter. - entity_get_display('node', $type, 'default') + $display_repository->getViewDisplay('node', $type) ->setComponent($integer_field, array( 'type' => 'number_integer', )) only in patch2: unchanged: --- a/core/modules/field/src/Tests/String/StringFieldTest.php +++ b/core/modules/field/src/Tests/String/StringFieldTest.php @@ -63,7 +63,11 @@ function _testTextfieldWidgets($field_type, $widget_type) { 'bundle' => 'entity_test', 'label' => $this->randomMachineName() . '_label', ])->save(); - entity_get_form_display('entity_test', 'entity_test', 'default') + + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getFormDisplay('entity_test', 'entity_test') ->setComponent($field_name, array( 'type' => $widget_type, 'settings' => array( @@ -71,7 +75,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { ), )) ->save(); - entity_get_display('entity_test', 'entity_test', 'full') + $display_repository->getViewDisplay('entity_test', 'entity_test', 'full') ->setComponent($field_name) ->save(); @@ -93,7 +97,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { // Display the entity. $entity = EntityTest::load($id); - $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); + $display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full'); $content = $display->build($entity); $this->setRawContent(\Drupal::service('renderer')->renderRoot($content)); $this->assertText($value, 'Filtered tags are not displayed'); only in patch2: unchanged: --- a/core/modules/field/src/Tests/reEnableModuleFieldTest.php +++ b/core/modules/field/src/Tests/reEnableModuleFieldTest.php @@ -56,7 +56,10 @@ function testReEnabledField() { 'label' => 'Telephone Number', ])->save(); - entity_get_form_display('node', 'article', 'default') + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + + $display_repository->getViewDisplay('node', 'article') ->setComponent('field_telephone', array( 'type' => 'telephone_default', 'settings' => array( @@ -65,7 +68,7 @@ function testReEnabledField() { )) ->save(); - entity_get_display('node', 'article', 'default') + $display_repository->getFormDisplay('node', 'article') ->setComponent('field_telephone', array( 'type' => 'telephone_link', 'weight' => 1, only in patch2: unchanged: --- a/core/modules/field/tests/src/Kernel/Boolean/BooleanFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/Boolean/BooleanFormatterTest.php @@ -71,7 +71,8 @@ protected function setUp() { ]); $instance->save(); - $this->display = entity_get_display($this->entityType, $this->bundle, 'default') + $this->display = $this->container->get('entity_display.repository') + ->getViewDisplay($this->entityType, $this->bundle) ->setComponent($this->fieldName, [ 'type' => 'boolean', 'settings' => [], only in patch2: unchanged: --- a/core/modules/field/tests/src/Kernel/DisplayApiTest.php +++ b/core/modules/field/tests/src/Kernel/DisplayApiTest.php @@ -97,15 +97,18 @@ protected function setUp() { ), ); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = $this->container->get('entity_display.repository'); + FieldStorageConfig::create($field_storage)->save(); FieldConfig::create($field)->save(); // Create a display for the default view mode. - entity_get_display($field['entity_type'], $field['bundle'], 'default') + $display_repository->getViewDisplay($field['entity_type'], $field['bundle']) ->setComponent($this->fieldName, $this->displayOptions['default']) ->save(); // Create a display for the teaser view mode. EntityViewMode::create(array('id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save(); - entity_get_display($field['entity_type'], $field['bundle'], 'teaser') + $display_repository->getViewDisplay($field['entity_type'], $field['bundle'], 'teaser') ->setComponent($this->fieldName, $this->displayOptions['teaser']) ->save(); only in patch2: unchanged: --- a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php @@ -39,7 +39,8 @@ function testEntityDisplayBuild() { // Simple formatter, label displayed. $entity = clone($entity_init); - $display = entity_get_display($entity_type, $entity->bundle(), 'full'); + $display = $this->container->get('entity_display.repository') + ->getViewDisplay($entity_type, $entity->bundle(), 'full'); $formatter_setting = $this->randomMachineName(); $display_options = array( @@ -135,7 +136,8 @@ function testEntityDisplayBuild() { */ function testEntityDisplayViewMultiple() { // Use a formatter that has a prepareView() step. - $display = entity_get_display('entity_test', 'entity_test', 'full') + $display = $this->container->get('entity_display.repository') + ->getViewDisplay('entity_test', 'entity_test', 'full') ->setComponent($this->fieldTestData->field_name, array( 'type' => 'field_test_with_prepare_view', ));