public function MenuLinkConfigForm::extractFormValues in Config menu link 8
Extracts a plugin definition from form values.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The new plugin definition values taken from the form values. The plugin ID must be returned as part of the definition.
Overrides MenuLinkFormInterface::extractFormValues
2 calls to MenuLinkConfigForm::extractFormValues()
- MenuLinkConfigForm::buildEntity in src/
Plugin/ Menu/ Form/ MenuLinkConfigForm.php - Builds an updated entity object based upon the submitted form values.
- MenuLinkConfigForm::submitConfigurationForm in src/
Plugin/ Menu/ Form/ MenuLinkConfigForm.php - Form submission handler.
File
- src/
Plugin/ Menu/ Form/ MenuLinkConfigForm.php, line 402 - Contains \Drupal\menu_link_config\Plugin\Menu\Form\MenuLinkConfigForm.
Class
Namespace
Drupal\menu_link_config\Plugin\Menu\FormCode
public function extractFormValues(array &$form, FormStateInterface $form_state) {
$new_definition = [];
$new_definition['title'] = $form_state
->getValue('title');
$extracted = $this
->extractUrl($form_state
->getValue('url'));
$new_definition['url'] = $extracted['url'];
$new_definition['route_name'] = $extracted['route_name'];
$new_definition['route_parameters'] = $extracted['route_parameters'];
$new_definition['options'] = [];
if ($extracted['query']) {
$new_definition['options']['query'] = $extracted['query'];
}
if ($extracted['fragment']) {
$new_definition['options']['fragment'] = $extracted['fragment'];
}
$new_definition['description'] = $form_state
->getValue('description');
$new_definition['hidden'] = !$form_state
->getValue('enabled');
$new_definition['weight'] = (int) $form_state
->getValue('weight');
$new_definition['expanded'] = (bool) $form_state
->getValue('expanded');
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;
}
$new_definition['metadata']['entity_id'] = $form_state
->getValue('id');
return $new_definition;
}