Skip to content
Snippets Groups Projects
Commit 84258cbc authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2680227 by k4v, stBorchert, dawehner: Views does not respect order of area handlers

parent e888be3f
No related branches found
No related tags found
No related merge requests found
......@@ -2217,6 +2217,10 @@ public function renderArea($area, $empty = FALSE) {
$return = array();
foreach ($this->getHandlers($area) as $key => $area_handler) {
if ($area_render = $area_handler->render($empty)) {
if (isset($area_handler->position)) {
// Fix weight of area.
$area_render['#weight'] = $area_handler->position;
}
$return[$key] = $area_render;
}
}
......
langcode: en
status: true
id: test_area_order
label: ''
module: views
description: ''
tag: ''
base_table: views_test_data
base_field: nid
core: '8'
display:
default:
display_options:
defaults:
fields: false
pager: false
sorts: false
header:
entity_block_2:
field: entity_block
id: entity_block
table: views
target: 'bartik_powered'
view_mode: full
plugin_id: entity
entity_block_1:
field: entity_block
id: entity_block
table: views
target: 'bartik_branding'
view_mode: full
plugin_id: entity
fields:
id:
field: id
id: id
relationship: none
table: views_test_data
plugin_id: numeric
arguments:
id:
id: id
table: views_test_data
field: id
plugin_id: numeric
pager:
options:
offset: 0
type: none
display_plugin: default
display_title: Master
id: default
position: 0
<?php
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\block\Entity\Block;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
/**
* Tests the view area handler.
*
* @group views
* @see \Drupal\views\Plugin\views\area\View
*/
class AreaOrderTest extends ViewsKernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('user', 'block');
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_area_order');
/**
* {@inheritdoc}
*/
protected function setUpFixtures() {
Block::create(
[
'id' => 'bartik_branding',
'theme' => 'bartik',
'plugin' => 'system_branding_block',
'weight' => 1,
]
)->save();
Block::create(
[
'id' => 'bartik_powered',
'theme' => 'bartik',
'plugin' => 'system_powered_by_block',
'weight' => 2,
]
)->save();
parent::setUpFixtures();
}
/**
* Tests the order of the handlers.
*/
public function testAreaOrder() {
$renderer = $this->container->get('renderer');
$view = Views::getView('test_area_order');
$renderable = $view->buildRenderable();
$output = $this->render($renderable);
$position_powered = strpos($output, 'block-bartik-powered');
$position_branding = strpos($output, 'block-bartik-branding');
$this->assertNotEquals(0, $position_powered, 'ID bartik-powered found.');
$this->assertNotEquals(0, $position_branding, 'ID bartik-branding found');
// Make sure "powered" is before "branding", so it reflects the position
// in the configuration, and not the weight of the blocks.
$this->assertTrue($position_powered < $position_branding, 'Block bartik-powered is positioned before block bartik-branding');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment