diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php index 6fbdeda..e31ed77 100644 --- a/core/lib/Drupal/Core/Entity/EntityListBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php @@ -9,7 +9,6 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Component\Utility\SafeMarkup; /** * Defines a generic implementation to build a listing of entities. @@ -106,16 +105,20 @@ protected function getEntityIds() { } /** - * Gets the escaped label of an entity. + * Gets the label of an entity. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity being listed. * * @return string - * The escaped entity label. + * The entity label. + * + * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0 + * Use $entity->label() instead. This method used to escape the entity + * label. The render system's autoescape is now relied upon. */ protected function getLabel(EntityInterface $entity) { - return SafeMarkup::checkPlain($entity->label()); + return $entity->label(); } /** diff --git a/core/modules/action/src/ActionListBuilder.php b/core/modules/action/src/ActionListBuilder.php index 2d3af86..6d8a14d 100644 --- a/core/modules/action/src/ActionListBuilder.php +++ b/core/modules/action/src/ActionListBuilder.php @@ -80,7 +80,7 @@ public function load() { */ public function buildRow(EntityInterface $entity) { $row['type'] = $entity->getType(); - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); if ($this->hasConfigurableActions) { $row += parent::buildRow($entity); } diff --git a/core/modules/block_content/src/BlockContentListBuilder.php b/core/modules/block_content/src/BlockContentListBuilder.php index 793428d..4c6f806 100644 --- a/core/modules/block_content/src/BlockContentListBuilder.php +++ b/core/modules/block_content/src/BlockContentListBuilder.php @@ -29,7 +29,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); return $row + parent::buildRow($entity); } diff --git a/core/modules/config/tests/config_test/src/ConfigTestListBuilder.php b/core/modules/config/tests/config_test/src/ConfigTestListBuilder.php index 8634b96..4680ea2 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestListBuilder.php +++ b/core/modules/config/tests/config_test/src/ConfigTestListBuilder.php @@ -30,7 +30,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); $row['id'] = $entity->id(); return $row + parent::buildRow($entity); } diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php index 275dfed..74e276a 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php @@ -65,7 +65,7 @@ public function buildRow(EntityInterface $entity) { $plugin_definition = $entity->getPlugin()->getPluginDefinition(); $row['label'] = array( - 'data' => $this->getLabel($entity), + 'data' => $entity->label(), 'class' => 'table-filter-text-source', ); diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php index 0c50f2a..367b6fa 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php @@ -68,7 +68,7 @@ public function render() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label']['data'] = $this->getLabel($entity); + $row['label']['data'] = $entity->label(); $row['label']['class'][] = 'table-filter-text-source'; return $row + parent::buildRow($entity); } diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php index a340707..1b2a08b 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php @@ -116,7 +116,7 @@ public function getFilterLabels() { */ public function buildRow(EntityInterface $entity) { $row['label'] = array( - 'data' => $this->getLabel($entity), + 'data' => $entity->label(), 'class' => 'table-filter-text-source', ); diff --git a/core/modules/contact/src/ContactFormListBuilder.php b/core/modules/contact/src/ContactFormListBuilder.php index 4ba3b36..ed027c1 100644 --- a/core/modules/contact/src/ContactFormListBuilder.php +++ b/core/modules/contact/src/ContactFormListBuilder.php @@ -35,7 +35,7 @@ public function buildHeader() { public function buildRow(EntityInterface $entity) { // Special case the personal form. if ($entity->id() == 'personal') { - $row['form'] = $this->getLabel($entity); + $row['form'] = $entity->label(); $row['recipients'] = t('Selected user'); $row['selected'] = t('No'); } diff --git a/core/modules/field_ui/src/EntityDisplayModeListBuilder.php b/core/modules/field_ui/src/EntityDisplayModeListBuilder.php index 906a8e0..1595963 100644 --- a/core/modules/field_ui/src/EntityDisplayModeListBuilder.php +++ b/core/modules/field_ui/src/EntityDisplayModeListBuilder.php @@ -68,7 +68,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); return $row + parent::buildRow($entity); } diff --git a/core/modules/filter/src/FilterFormatListBuilder.php b/core/modules/filter/src/FilterFormatListBuilder.php index 89b4c96..5ae317e 100644 --- a/core/modules/filter/src/FilterFormatListBuilder.php +++ b/core/modules/filter/src/FilterFormatListBuilder.php @@ -93,7 +93,7 @@ public function buildHeader() { public function buildRow(EntityInterface $entity) { // Check whether this is the fallback text format. This format is available // to all roles and cannot be disabled via the admin interface. - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); $row['roles'] = []; if ($entity->isFallbackFormat()) { $fallback_choice = $this->configFactory->get('filter.settings')->get('always_show_fallback_choice'); diff --git a/core/modules/image/src/ImageStyleListBuilder.php b/core/modules/image/src/ImageStyleListBuilder.php index b0ad227..191314c 100644 --- a/core/modules/image/src/ImageStyleListBuilder.php +++ b/core/modules/image/src/ImageStyleListBuilder.php @@ -67,7 +67,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); return $row + parent::buildRow($entity); } diff --git a/core/modules/language/src/LanguageListBuilder.php b/core/modules/language/src/LanguageListBuilder.php index 77deb01..2f80578 100644 --- a/core/modules/language/src/LanguageListBuilder.php +++ b/core/modules/language/src/LanguageListBuilder.php @@ -107,7 +107,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); $row['default'] = array( '#type' => 'radio', '#parents' => array('site_default_language'), diff --git a/core/modules/menu_ui/src/MenuListBuilder.php b/core/modules/menu_ui/src/MenuListBuilder.php index 95d029c..be9fc1e 100644 --- a/core/modules/menu_ui/src/MenuListBuilder.php +++ b/core/modules/menu_ui/src/MenuListBuilder.php @@ -36,7 +36,7 @@ public function buildHeader() { */ public function buildRow(EntityInterface $entity) { $row['title'] = array( - 'data' => $this->getLabel($entity), + 'data' => $entity->label(), 'class' => array('menu-label'), ); $row['description']['data'] = ['#markup' => $entity->getDescription()]; diff --git a/core/modules/node/src/NodeTypeListBuilder.php b/core/modules/node/src/NodeTypeListBuilder.php index 89ea825..ddefa51 100644 --- a/core/modules/node/src/NodeTypeListBuilder.php +++ b/core/modules/node/src/NodeTypeListBuilder.php @@ -35,7 +35,7 @@ public function buildHeader() { */ public function buildRow(EntityInterface $entity) { $row['title'] = array( - 'data' => $this->getLabel($entity), + 'data' => $entity->label(), 'class' => array('menu-label'), ); $row['description']['data'] = ['#markup' => $entity->getDescription()]; diff --git a/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php b/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php index 5a3da8d..879313f 100644 --- a/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php +++ b/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php @@ -28,7 +28,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); $row['id'] = $entity->id(); return $row + parent::buildRow($entity); } diff --git a/core/modules/search/src/SearchPageListBuilder.php b/core/modules/search/src/SearchPageListBuilder.php index 9095513..b25c499 100644 --- a/core/modules/search/src/SearchPageListBuilder.php +++ b/core/modules/search/src/SearchPageListBuilder.php @@ -121,7 +121,7 @@ public function buildHeader() { */ public function buildRow(EntityInterface $entity) { /** @var $entity \Drupal\search\SearchPageInterface */ - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); $row['url']['#markup'] = 'search/' . $entity->getPath(); // If the search page is active, link to it. if ($entity->status()) { diff --git a/core/modules/shortcut/src/Form/SwitchShortcutSet.php b/core/modules/shortcut/src/Form/SwitchShortcutSet.php index 5388db5..9bc34ca 100644 --- a/core/modules/shortcut/src/Form/SwitchShortcutSet.php +++ b/core/modules/shortcut/src/Form/SwitchShortcutSet.php @@ -7,7 +7,6 @@ namespace Drupal\shortcut\Form; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -71,7 +70,7 @@ public function buildForm(array $form, FormStateInterface $form_state, UserInter // Prepare the list of shortcut sets. $options = array_map(function (ShortcutSet $set) { - return SafeMarkup::checkPlain($set->label()); + return $set->label(); }, $this->shortcutSetStorage->loadMultiple()); $current_set = shortcut_current_displayed_set($this->user); diff --git a/core/modules/shortcut/src/ShortcutSetListBuilder.php b/core/modules/shortcut/src/ShortcutSetListBuilder.php index 9de658d..cf5c464 100644 --- a/core/modules/shortcut/src/ShortcutSetListBuilder.php +++ b/core/modules/shortcut/src/ShortcutSetListBuilder.php @@ -46,7 +46,7 @@ public function getDefaultOperations(EntityInterface $entity) { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['name'] = $this->getLabel($entity); + $row['name'] = $entity->label(); return $row + parent::buildRow($entity); } diff --git a/core/modules/system/src/DateFormatListBuilder.php b/core/modules/system/src/DateFormatListBuilder.php index 29b201c..2f052d9 100644 --- a/core/modules/system/src/DateFormatListBuilder.php +++ b/core/modules/system/src/DateFormatListBuilder.php @@ -68,7 +68,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); $row['pattern'] = $this->dateFormatter->format(REQUEST_TIME, $entity->id()); return $row + parent::buildRow($entity); } diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestListBuilder.php b/core/modules/system/tests/modules/entity_test/src/EntityTestListBuilder.php index 1fbc8a1..c3a9cba 100644 --- a/core/modules/system/tests/modules/entity_test/src/EntityTestListBuilder.php +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestListBuilder.php @@ -30,7 +30,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); $row['id'] = $entity->id(); return $row + parent::buildRow($entity); } diff --git a/core/modules/taxonomy/src/VocabularyListBuilder.php b/core/modules/taxonomy/src/VocabularyListBuilder.php index fe196c9..88f2594 100644 --- a/core/modules/taxonomy/src/VocabularyListBuilder.php +++ b/core/modules/taxonomy/src/VocabularyListBuilder.php @@ -68,7 +68,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); return $row + parent::buildRow($entity); } diff --git a/core/modules/user/src/RoleListBuilder.php b/core/modules/user/src/RoleListBuilder.php index 4e0dd73..b2b9e54 100644 --- a/core/modules/user/src/RoleListBuilder.php +++ b/core/modules/user/src/RoleListBuilder.php @@ -37,7 +37,7 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = $this->getLabel($entity); + $row['label'] = $entity->label(); return $row + parent::buildRow($entity); } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php index b76ce38..79447e5 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php @@ -137,64 +137,6 @@ public function testGetOperations() { $this->assertArrayHasKey('title', $operations[$operation_name]); } - /** - * Tests that buildRow() returns a string which has been run through - * SafeMarkup::checkPlain(). - * - * @dataProvider providerTestBuildRow - * - * @param string $input - * The entity label being passed into buildRow. - * @param string $expected - * The expected output of the label from buildRow. - * @param string $message - * The message to provide as output for the test. - * @param bool $ignorewarnings - * Whether or not to ignore PHP 5.3+ invalid multibyte sequence warnings. - * - * @see \Drupal\Core\Entity\EntityListBuilder::buildRow() - */ - public function testBuildRow($input, $expected, $message, $ignorewarnings = FALSE) { - $this->role->expects($this->any()) - ->method('label') - ->will($this->returnValue($input)); - - if ($ignorewarnings) { - $built_row = @$this->entityListBuilder->buildRow($this->role); - } - else { - $built_row = $this->entityListBuilder->buildRow($this->role); - } - - $this->assertEquals($built_row['label'], $expected, $message); - } - - /** - * Data provider for testBuildRow(). - * - * @see self::testBuildRow() - * @see \Drupal\Tests\Component\Utility\SafeMarkupTest::providerCheckPlain() - * - * @return array - * An array containing a string, the expected return from - * SafeMarkup::checkPlain, a message to be output for failures, and whether the - * test should be processed as multibyte. - */ - public function providerTestBuildRow() { - $tests = array(); - // Checks that invalid multi-byte sequences are escaped. - $tests[] = array("Foo\xC0barbaz", 'Foo�barbaz', 'EntityTestListBuilder::buildRow() escapes invalid sequence "Foo\xC0barbaz"', TRUE); - $tests[] = array("\xc2\"", '�"', 'EntityTestListBuilder::buildRow escapes invalid sequence "\xc2\""', TRUE); - $tests[] = array("Fooÿñ", "Fooÿñ", 'EntityTestListBuilder::buildR does not escape valid sequence "Fooÿñ"'); - - // Checks that special characters are escaped. - $tests[] = array("