Issue #2306611 by rbayliss: Fixed Field weights are not respected on render.

8.0.x
Alex Pott 2014-07-21 11:13:39 +01:00
parent aeb6df2aa0
commit 01bb1268aa
2 changed files with 19 additions and 1 deletions

View File

@ -275,7 +275,7 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
// taken care of in EntityViewDisplay::buildMultiple().
foreach ($display->getComponents() as $name => $options) {
if (isset($build_list[$key][$name])) {
$build_list[$key]['#weight'] = $options['weight'];
$build_list[$key][$name]['#weight'] = $options['weight'];
}
}

View File

@ -153,6 +153,24 @@ class EntityViewBuilderTest extends EntityUnitTestBase {
$this->assertTrue(isset($build['#cache']) && array_keys($build['#cache']) == array('tags'), 'An entity type can opt out of render caching regardless of view mode configuration, but always has cache tags set.');
}
/**
* Tests weighting of display components.
*/
public function testEntityViewBuilderWeight() {
// Set a weight for the label component.
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent('label', array('weight' => 20))
->save();
// Create and build a test entity.
$entity_test = $this->createTestEntity('entity_test');
$view = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'full');
drupal_render($view);
// Check that the weight is respected.
$this->assertEqual($view['label']['#weight'], 20, 'The weight of a display component is respected.');
}
/**
* Creates an entity for testing.
*