/**
  * {@inheritdoc}
  */
 function updateConfiguration(array $types)
 {
     // Ensure that we are getting the defined language negotiation information.
     // An invocation of \Drupal\Core\Extension\ModuleHandler::install() or
     // \Drupal\Core\Extension\ModuleHandler::uninstall() could invalidate the
     // cached information.
     $this->negotiatorManager->clearCachedDefinitions();
     $this->languageManager->reset();
     $language_types = array();
     $language_types_info = $this->languageManager->getDefinedLanguageTypesInfo();
     $method_definitions = $this->getNegotiationMethods();
     foreach ($language_types_info as $type => $info) {
         $configurable = in_array($type, $types);
         // The default language negotiation settings, if available, are stored in
         // $info['fixed'].
         $has_default_settings = !empty($info['fixed']);
         // Check whether the language type is unlocked. Only the status of
         // unlocked language types can be toggled between configurable and
         // non-configurable.
         if (empty($info['locked'])) {
             if (!$configurable && !$has_default_settings) {
                 // If we have an unlocked non-configurable language type without
                 // default language negotiation settings, we use the values
                 // negotiated for the interface language which, should always be
                 // available.
                 $method_weights = array(LanguageNegotiationUI::METHOD_ID);
                 $method_weights = array_flip($method_weights);
                 $this->saveConfiguration($type, $method_weights);
             }
         } else {
             // The language type is locked. Locked language types with default
             // settings are always considered non-configurable. In turn if default
             // settings are missing, the language type is always considered
             // configurable.
             // If the language type is locked we can just store its default language
             // negotiation settings if it has some, since it is not configurable.
             if ($has_default_settings) {
                 $method_weights = array();
                 // Default settings are in $info['fixed'].
                 foreach ($info['fixed'] as $weight => $method_id) {
                     if (isset($method_definitions[$method_id])) {
                         $method_weights[$method_id] = $weight;
                     }
                 }
                 $this->saveConfiguration($type, $method_weights);
             } else {
                 // It was missing default settings, so force it to be configurable.
                 $configurable = TRUE;
             }
         }
         // Accumulate information for each language type so it can be saved later.
         $language_types[$type] = $configurable;
     }
     // Store the language type configuration.
     $config = array('configurable' => array_keys(array_filter($language_types)), 'all' => array_keys($language_types));
     $this->languageManager->saveLanguageTypesConfiguration($config);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $configurable = $this->languageTypes->get('configurable');
     $form = array('#theme' => 'language_negotiation_configure_form', '#language_types_info' => $this->languageManager->getDefinedLanguageTypesInfo(), '#language_negotiation_info' => $this->negotiator->getNegotiationMethods());
     $form['#language_types'] = array();
     foreach ($form['#language_types_info'] as $type => $info) {
         // Show locked language types only if they are configurable.
         if (empty($info['locked']) || in_array($type, $configurable)) {
             $form['#language_types'][] = $type;
         }
     }
     foreach ($form['#language_types'] as $type) {
         $this->configureFormTable($form, $type);
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#button_type' => 'primary', '#value' => $this->t('Save settings'));
     return $form;
 }