function ShortcutSet::resetLinkWeights

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

Overrides ShortcutSetInterface::resetLinkWeights

File

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

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.