/**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $enabled_methods = array_filter($form_state->getValue('enabled'));
     ksort($enabled_methods);
     $method_weights = $form_state->getValue('weight');
     ksort($method_weights);
     $machine_name = $form_state->getValue(array('bundle', 'machine_name'));
     // If this is a new bundle, create it.
     if ($form_state->getValue(array('bundle', 'bundle_select')) == self::NEW_BUNDLE_SELECT_VALUE) {
         $bundle = $this->assigner->createBundleFromDefault($machine_name);
     } else {
         $bundle = $this->assigner->loadBundle();
         $old_name = $bundle->getMachineName();
         $new_name = $form_state->getValue(array('bundle', 'machine_name'));
         if ($old_name != $new_name) {
             $bundle = $this->assigner->renameBundle($old_name, $new_name);
         }
     }
     $bundle->setName($form_state->getValue(array('bundle', 'name')));
     $bundle->setDescription($form_state->getValue(array('bundle', 'description')));
     $bundle->setEnabledAssignments(array_keys($enabled_methods));
     $bundle->setAssignmentWeights($method_weights);
     $bundle->setIsProfile($form_state->getValue(array('bundle', 'is_profile')));
     $bundle->setProfileName($form_state->getValue(array('bundle', 'profile_name')));
     $bundle->save();
     $this->assigner->setBundle($bundle);
     $this->assigner->setCurrent($bundle);
     $form_state->setRedirect('features.assignment');
     drupal_set_message($this->t('Package assignment configuration saved.'));
 }