function MenuLinkDefaultForm::extractFormValues

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php \Drupal\Core\Menu\Form\MenuLinkDefaultForm::extractFormValues()
  2. 10 core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php \Drupal\Core\Menu\Form\MenuLinkDefaultForm::extractFormValues()
  3. 11.x core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php \Drupal\Core\Menu\Form\MenuLinkDefaultForm::extractFormValues()

Overrides MenuLinkFormInterface::extractFormValues

2 calls to MenuLinkDefaultForm::extractFormValues()
MenuLinkDefaultForm::submitConfigurationForm in core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
Form submission handler.
ViewsMenuLinkForm::extractFormValues in core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php
Extracts a plugin definition from form values.
1 method overrides MenuLinkDefaultForm::extractFormValues()
ViewsMenuLinkForm::extractFormValues in core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php
Extracts a plugin definition from form values.

File

core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php, line 152

Class

MenuLinkDefaultForm
Provides an edit form for static menu links.

Namespace

Drupal\Core\Menu\Form

Code

public function extractFormValues(array &$form, FormStateInterface $form_state) {
    // Start from the complete, original, definition.
    $new_definition = $this->menuLink
        ->getPluginDefinition();
    // Since the ID may not be present in the definition used to construct the
    // plugin, add it here so it's available to any consumers of this method.
    $new_definition['id'] = $form_state->getValue('id');
    $new_definition['enabled'] = $form_state->getValue('enabled') ? 1 : 0;
    $new_definition['weight'] = (int) $form_state->getValue('weight');
    $new_definition['expanded'] = $form_state->getValue('expanded') ? 1 : 0;
    list($menu_name, $parent) = explode(':', $form_state->getValue('menu_parent'), 2);
    if (!empty($menu_name)) {
        $new_definition['menu_name'] = $menu_name;
    }
    if (isset($parent)) {
        $new_definition['parent'] = $parent;
    }
    return $new_definition;
}

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