function LocalTaskDefault::getWeight

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/LocalTaskDefault.php \Drupal\Core\Menu\LocalTaskDefault::getWeight()
  2. 8.9.x core/lib/Drupal/Core/Menu/LocalTaskDefault.php \Drupal\Core\Menu\LocalTaskDefault::getWeight()
  3. 10 core/lib/Drupal/Core/Menu/LocalTaskDefault.php \Drupal\Core\Menu\LocalTaskDefault::getWeight()

Returns the weight of the local task.

Return value

int The weight of the task. If not defined in the annotation returns 0 by default or -10 for the root tab.

Overrides LocalTaskInterface::getWeight

File

core/lib/Drupal/Core/Menu/LocalTaskDefault.php, line 91

Class

LocalTaskDefault
Default object used for LocalTaskPlugins.

Namespace

Drupal\Core\Menu

Code

public function getWeight() {
    // By default the weight is 0, or -10 for the root tab.
    if (!isset($this->pluginDefinition['weight'])) {
        if ($this->pluginDefinition['base_route'] == $this->pluginDefinition['route_name']) {
            $this->pluginDefinition['weight'] = -10;
        }
        else {
            $this->pluginDefinition['weight'] = 0;
        }
    }
    return (int) $this->pluginDefinition['weight'];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.