function ShortcutSet::resetLinkWeights

Same name in other branches
  1. 9 core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::resetLinkWeights()
  2. 8.9.x core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::resetLinkWeights()
  3. 10 core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::resetLinkWeights()

Overrides ShortcutSetInterface::resetLinkWeights

File

core/modules/shortcut/src/Entity/ShortcutSet.php, line 119

Class

ShortcutSet
Defines the Shortcut set configuration entity.

Namespace

Drupal\shortcut\Entity

Code

public function resetLinkWeights() {
    $weight = -50;
    foreach ($this->getShortcuts() as $shortcut) {
        $shortcut->setWeight(++$weight);
        $shortcut->save();
    }
    return $this;
}

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