diff --git a/core/modules/image/lib/Drupal/image/Plugin/field/formatter/ImageFormatter.php b/core/modules/image/lib/Drupal/image/Plugin/field/formatter/ImageFormatter.php index 0ee4fd0..938a53a 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/field/formatter/ImageFormatter.php +++ b/core/modules/image/lib/Drupal/image/Plugin/field/formatter/ImageFormatter.php @@ -122,12 +122,8 @@ public function viewElements(EntityInterface $entity, $langcode, FieldInterface ); // Passes HTML data attributes to the theme function. if (isset($item->html_data_attributes)) { - if (isset($elements[$delta]['#item']['attributes'])) { - $elements[$delta]['#item']['attributes'] += $item->html_data_attributes; - } - else { - $elements[$delta]['#item']['attributes'] = $item->html_data_attributes; - } + $elements[$delta]['#item'] += array('attributes' => array()); + $elements[$delta]['#item']['attributes'] += $item->html_data_attributes; } } } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php index a3f73f8..43ceb20 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php @@ -6,9 +6,9 @@ namespace Drupal\rdf\Tests\Field; -use Drupal\node\Tests\NodeTestBase; +use Drupal\field\Tests\FieldUnitTestBase; -abstract class FieldRdfaTestBase extends NodeTestBase { +abstract class FieldRdfaTestBase extends FieldUnitTestBase { /** * The machine name of the field type to test. @@ -45,13 +45,6 @@ */ public static $modules = array('rdf'); - function setUp() { - parent::setUp(); - - // Creates test content type. - $this->drupalCreateContentType(array('type' => 'test_node_type')); - } - /** * Helper function to test the formatter's RDFa. * @@ -67,11 +60,12 @@ function setUp() { protected function assertFormatterRdfa($formatter, $property, $value, $object_type = 'literal') { // The field formatter will be rendered inside the entity. Sets the field // formatter in the entity display options before rendering the entity. - entity_get_display('node', 'test_node_type', 'default') + entity_get_display('entity_test_render', 'entity_test_render', 'default') ->setComponent($this->fieldName, array('type' => $formatter)) ->save(); - $build = entity_view_multiple(array($this->entity), 'default'); - $graph = new \EasyRdf_Graph($this->uri, drupal_render($build), 'rdfa'); + $build = entity_view($this->entity, 'default'); + $output = drupal_render($build); + $graph = new \EasyRdf_Graph($this->uri, $output, 'rdfa'); $expected_value = array( 'type' => $object_type, @@ -89,9 +83,9 @@ protected function createTestField() { 'type' => $this->fieldType, ))->save(); entity_create('field_instance', array( - 'entity_type' => 'node', + 'entity_type' => 'entity_test_render', 'field_name' => $this->fieldName, - 'bundle' => 'test_node_type', + 'bundle' => 'entity_test_render', ))->save(); } 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 6572de5..3d7df64 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php @@ -19,7 +19,7 @@ class TaxonomyTermReferenceRdfaTest extends FieldRdfaTestBase { /** * The term for testing. * - * @var \Drupal\taxonomy\Plugin\Core\Entity\Term + * @var \Drupal\taxonomy\Entity\Term */ protected $term; @@ -46,6 +46,8 @@ public static function getInfo() { public function setUp() { parent::setUp(); + $this->installSchema('taxonomy', array('taxonomy_term_data', 'taxonomy_term_hierarchy')); + $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), @@ -67,10 +69,11 @@ public function setUp() { ), ))->save(); entity_create('field_instance', array( - 'entity_type' => 'node', + 'entity_type' => 'entity_test_render', 'field_name' => $this->fieldName, - 'bundle' => 'test_node_type', + 'bundle' => 'entity_test_render', ))->save(); + $this->term = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $vocabulary->id(), @@ -79,14 +82,14 @@ public function setUp() { $this->term->save(); // Add the mapping. - $mapping = rdf_get_mapping('node', 'test_node_type'); + $mapping = rdf_get_mapping('entity_test_render', 'entity_test_render'); $mapping->setFieldMapping($this->fieldName, array( 'properties' => array('schema:about'), ))->save(); // Set up test values. - $this->entity = $this->drupalCreateNode(array('type' => 'test_node_type')); - $this->entity->get($this->fieldName)->offsetGet(0)->get('target_id')->setValue($this->term->id()); + $this->entity = entity_create('entity_test_render', array()); + $this->entity->{$this->fieldName}->target_id = $this->term->id(); $this->entity->save(); $this->uri = $this->getAbsoluteUri($this->entity); } @@ -95,7 +98,6 @@ public function setUp() { * Tests the plain formatter. */ public function testPlainFormatter() { - $term_uri = $this->getAbsoluteUri($this->term); $this->assertFormatterRdfa('taxonomy_term_reference_plain', 'http://schema.org/about', $this->term->label(), 'literal'); } diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index ddb83d5..9b8db3d 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -202,7 +202,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) { function rdf_entity_prepare_view($entity_type, array $entities, array $displays) { // Iterates over the RDF mappings for each entity and prepares the RDFa // attributes to be added inside field formatters. - foreach ($entities as $id => $entity) { + foreach ($entities as $entity) { $mapping = rdf_get_mapping($entity_type, $entity->bundle()); // Only prepares the RDFa attributes for the fields which are configured // to be displayed. diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 7ed1763..94fbd21 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -8,7 +8,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Language\Language; -use Drupal\Core\Template\Attribute; use Drupal\Core\Utility\ModuleInfo; use Drupal\system\Plugin\Block\SystemMenuBlock; use Drupal\user\UserInterface; 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 cb1a40e..62ad9a9 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 @@ -52,9 +52,7 @@ public function viewElements(EntityInterface $entity, $langcode, FieldInterface ); if (!empty($item->html_data_attributes)) { - if (!isset($elements[$delta]['#options']['attributes'])) { - $elements[$delta]['#options']['attributes'] = array(); - } + $elements[$delta]['#options'] += array('attributes' => array()); $elements[$delta]['#options']['attributes'] += $item->html_data_attributes; } }