diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install index e236628..a423636 100644 --- a/core/modules/aggregator/aggregator.install +++ b/core/modules/aggregator/aggregator.install @@ -37,3 +37,16 @@ function aggregator_update_8001() { /** * @} End of "addtogroup updates-8.0.0-rc". */ + +/** + * Promote 'guid' field to uuid entity key. + */ +function aggregator_update_8002() { + $manager = \Drupal::entityDefinitionUpdateManager(); + $entity_type = $manager->getEntityType('aggregator_item'); + $entity_keys = $entity_type->getKeys(); + $entity_keys['uuid'] = 'guid'; + $entity_type->set('entity_keys', $entity_keys); + $manager->updateEntityType($entity_type); + $manager->updateFieldStorageDefinition($manager->getFieldStorageDefinition('guid', 'aggregator_item')); +} diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php index 4c6d104..c5543e6 100644 --- a/core/modules/aggregator/src/Entity/Item.php +++ b/core/modules/aggregator/src/Entity/Item.php @@ -36,6 +36,7 @@ * "id" = "iid", * "label" = "title", * "langcode" = "langcode", + * "uuid" = "guid", * } * ) */ @@ -109,11 +110,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { )) ->setDisplayConfigurable('view', TRUE); - // @todo Convert to a real UUID field in - // https://www.drupal.org/node/2149851. - $fields['guid'] = BaseFieldDefinition::create('string_long') + $fields['guid'] = BaseFieldDefinition::create('uuid') ->setLabel(t('GUID')) - ->setDescription(t('Unique identifier for the feed item.')); + ->setDescription(t('Unique identifier for the feed item.')) + ->setReadOnly(TRUE); return $fields; } diff --git a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php index 98598c4..8b2e559 100644 --- a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php +++ b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php @@ -91,7 +91,7 @@ public function testAggregatorItemView() { // Add a image to ensure that the sanitizing can be tested below. $values['author'] = $this->randomMachineName() . '"'; $values['link'] = 'https://www.drupal.org/node/' . mt_rand(1000, 10000); - $values['guid'] = $this->randomString(); + $values['guid'] = 'guid-' . $i; $aggregator_item = $this->itemStorage->create($values); $aggregator_item->save(); @@ -134,6 +134,16 @@ public function testAggregatorItemView() { }); $this->assertEqual($output, $expected_description, 'Ensure the author got filtered'); } + + // Test if an aggregator item can be rendered in the header. + $view = Views::getView('test_aggregator_items'); + $view->setDisplay('default'); + $this->executeView($view); + $output = $view->render(); + $output = \Drupal::service('renderer')->renderRoot($output); + $this->setRawContent($output); + $header = $this->cssSelect('header h3 a'); + $this->assertEqual(trim($header[0]), $expected[1]['title']); } } diff --git a/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml b/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml index db7b203..6776ef2 100644 --- a/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml +++ b/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml @@ -182,6 +182,20 @@ display: entity_type: aggregator_item entity_field: iid order: 'ASC' + header: + entity_aggregator_item: + id: entity_aggregator_item + table: views + field: entity_aggregator_item + relationship: none + group_type: group + admin_label: '' + empty: false + tokenize: true + target: guid-1 + view_mode: default + bypass_access: true + plugin_id: entity feed_1: display_plugin: feed id: feed_1