You are here

protected function LingotekSettingsTabPreferencesForm::saveAdminMenu in Lingotek Translation 3.2.x

Same name and namespace in other branches
  1. 8 src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  2. 8.2 src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  3. 4.0.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  4. 3.0.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  5. 3.1.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  6. 3.3.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  7. 3.4.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  8. 3.5.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  9. 3.6.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  10. 3.7.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
  11. 3.8.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveAdminMenu()
1 call to LingotekSettingsTabPreferencesForm::saveAdminMenu()
LingotekSettingsTabPreferencesForm::submitForm in src/Form/LingotekSettingsTabPreferencesForm.php
Form submission handler.

File

src/Form/LingotekSettingsTabPreferencesForm.php, line 263

Class

LingotekSettingsTabPreferencesForm
Configure Lingotek

Namespace

Drupal\lingotek\Form

Code

protected function saveAdminMenu($form_values) {
  $updated_values = [];
  $should_reset_cache = FALSE;

  /** @var \Drupal\Core\Menu\MenuLinkManager $menu_link_manager */
  $menu_link_manager = \Drupal::service('plugin.manager.menu.link');

  // Only run if there's been a change to avoid clearing the cache if we don't have to
  if ($this->top_level_value != $form_values['hide_top_level']) {
    if ($form_values['hide_top_level']) {
      $updated_values = [
        'enabled' => 0,
      ];
    }
    else {
      $updated_values = [
        'enabled' => 1,
      ];
    }
    $menu_link_manager
      ->updateDefinition('lingotek.dashboard', $updated_values);
    $ids = $menu_link_manager
      ->getChildIds('lingotek.dashboard');
    foreach ($ids as $child_link) {
      $menu_link_manager
        ->updateDefinition($child_link, $updated_values);
    }
    if ($updated_values['enabled']) {
      $menu_link_manager
        ->resetLink('lingotek.dashboard');
    }
    $should_reset_cache = TRUE;
  }
  if ($should_reset_cache) {
    drupal_flush_all_caches();
  }
}