function _menus_attribute_form_submit_handler in Menus attribute 8
Submit handler.
1 string reference to '_menus_attribute_form_submit_handler'
- menus_attribute_form_alter in ./
menus_attribute.module - Implements hook_form_FORM_ID_alter().
File
- ./
menus_attribute.module, line 121 - Provides alters for menus_attribute.
Code
function _menus_attribute_form_submit_handler(&$form, &$form_state) {
$instance = StorageHelper::instance();
$get_path = explode("/", \Drupal::service('path.current')
->getPath());
if ($get_path[6] == 'edit') {
if ($form['#form_id'] == 'menu_link_content_menu_link_content_form') {
$id = $get_path[5];
$plugin_id = \Drupal::entityTypeManager()
->getStorage('menu_link_content')
->load($id)
->getPluginId();
}
if ($form['#form_id'] == 'menu_link_edit') {
$plugin_id = $get_path[5];
}
}
else {
$plugin_id = $form_state
->getBuildInfo()['callback_object']
->getEntity()
->getPluginId();
}
foreach ($form_state
->getValues() as $key => $value) {
$temp[$key] = $value;
}
$instance
->exists($plugin_id) ? $instance
->update($temp, $plugin_id) : $instance
->add($temp, $plugin_id);
}