diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php index f04d0ab..9ac3073 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php @@ -84,7 +84,6 @@ public function setUp() { $mapping = rdf_get_mapping('entity_test', 'entity_test'); $mapping->setFieldMapping($this->fieldName, array( 'properties' => array('schema:about'), - 'mapping_type' => 'rel', ))->save(); // Set up test values. @@ -95,10 +94,18 @@ public function setUp() { } /** + * Tests the plain formatter. + */ + public function testPlainFormatter() { + $term_uri = $this->getAbsoluteUri($this->term); + $this->_testFormatter('taxonomy_term_reference_plain', 'http://schema.org/about', $term_uri, 'uri'); + } + + /** * Test the link formatter. */ public function testLinkFormatter() { - $term_uri = 'http://ex.com/taxonomy/term/1'; + $term_uri = $this->getAbsoluteUri($this->term); $this->_testFormatter('taxonomy_term_reference_link', 'http://schema.org/about', $term_uri, 'uri'); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php index b44002e..51ebdd7 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php @@ -50,6 +50,13 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { '#href' => $uri['path'], '#options' => $uri['options'], ); + + if (!empty($item['html_data_attributes'])) { + if (!isset($elements[$delta]['#options']['attributes'])) { + $elements[$delta]['#options']['attributes'] = array(); + } + $elements[$delta]['#options']['attributes'] += $item['html_data_attributes']; + } } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php index 90f76ad..00e5cc3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php @@ -24,6 +24,8 @@ * unsets values for invalid terms that do not exist. */ public function prepareView(array $entities, $langcode, array &$items) { + parent::prepareView($entities, $langcode, $items); + $tids = array(); // Collect every possible term attached to any of the fieldable entities.