Issue #2100651 by dawehner, neclimdul: Fixed local task plugin id check for derivatives.
parent
e9843f499e
commit
c2d9dfcacf
|
@ -88,7 +88,7 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface {
|
|||
public function getWeight() {
|
||||
// By default the weight is 0, or -10 for the root tab.
|
||||
if (!isset($this->pluginDefinition['weight'])) {
|
||||
if ($this->pluginDefinition['tab_root_id'] == $this->pluginDefinition['id']) {
|
||||
if ($this->pluginDefinition['tab_root_id'] == $this->pluginId) {
|
||||
$this->pluginDefinition['weight'] = -10;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -191,21 +191,34 @@ class LocalTaskDefaultTest extends UnitTestCase {
|
|||
*/
|
||||
public function providerTestGetWeight() {
|
||||
return array(
|
||||
array(array('weight' => 314), 314),
|
||||
// Manually specify a weight, so this is used.
|
||||
array(array('weight' => 314), 'test_id', 314),
|
||||
// Ensure that a default tab get a lower weight.
|
||||
array(
|
||||
array(
|
||||
'tab_root_id' => 'local_task_default',
|
||||
'id' => 'local_task_default'
|
||||
),
|
||||
'local_task_default',
|
||||
-10
|
||||
),
|
||||
// If the root ID is different to the ID of the tab, ignore it.
|
||||
array(
|
||||
array(
|
||||
'tab_root_id' => 'local_task_example',
|
||||
'id' => 'local_task_default'
|
||||
),
|
||||
0
|
||||
'local_task_default',
|
||||
0,
|
||||
),
|
||||
// Ensure that a default tab of a derivative gets the default value.
|
||||
array(
|
||||
array(
|
||||
'tab_root_id' => 'local_task_derivative_default:example_id',
|
||||
'id' => 'local_task_derivative_default'
|
||||
),
|
||||
'local_task_derivative_default:example_id',
|
||||
-10,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -217,8 +230,9 @@ class LocalTaskDefaultTest extends UnitTestCase {
|
|||
*
|
||||
* @see \Drupal\Core\Menu\LocalTaskDefault::getWeight()
|
||||
*/
|
||||
public function testGetWeight(array $plugin_definition, $expected_weight) {
|
||||
public function testGetWeight(array $plugin_definition, $plugin_id, $expected_weight) {
|
||||
$this->pluginDefinition = $plugin_definition;
|
||||
$this->pluginId = $plugin_id;
|
||||
$this->setupLocalTaskDefault();
|
||||
|
||||
$this->assertEquals($expected_weight, $this->localTaskBase->getWeight());
|
||||
|
|
Loading…
Reference in New Issue