public function ShortcutSet::resetLinkWeights in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::resetLinkWeights()
Resets the link weights in a shortcut set to match their current order.
This function can be used, for example, when a new shortcut link is added to the set. If the link is added to the end of the array and this function is called, it will force that link to display at the end of the list.
Return value
\Drupal\shortcut\ShortcutSetInterface The shortcut set.
Overrides ShortcutSetInterface::resetLinkWeights
File
- core/
modules/ shortcut/ src/ Entity/ ShortcutSet.php, line 110 - Contains \Drupal\shortcut\Entity\ShortcutSet.
Class
- ShortcutSet
- Defines the Shortcut set configuration entity.
Namespace
Drupal\shortcut\EntityCode
public function resetLinkWeights() {
$weight = -50;
foreach ($this
->getShortcuts() as $shortcut) {
$shortcut
->setWeight(++$weight);
$shortcut
->save();
}
return $this;
}