function SetCustomize::save

Same name and namespace in other branches
  1. 9 core/modules/shortcut/src/Form/SetCustomize.php \Drupal\shortcut\Form\SetCustomize::save()
  2. 8.9.x core/modules/shortcut/src/Form/SetCustomize.php \Drupal\shortcut\Form\SetCustomize::save()
  3. 10 core/modules/shortcut/src/Form/SetCustomize.php \Drupal\shortcut\Form\SetCustomize::save()

Overrides EntityForm::save

File

core/modules/shortcut/src/Form/SetCustomize.php, line 105

Class

SetCustomize
Builds the shortcut set customize form.

Namespace

Drupal\shortcut\Form

Code

public function save(array $form, FormStateInterface $form_state) {
    foreach ($this->entity
        ->getShortcuts() as $shortcut) {
        $weight = $form_state->getValue([
            'shortcuts',
            'links',
            $shortcut->id(),
            'weight',
        ]);
        $shortcut->setWeight($weight);
        $shortcut->save();
    }
    $this->messenger()
        ->addStatus($this->t('The shortcut set has been updated.'));
}

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