You are here

public function FeaturesEditForm::updateBundle in Features 8.3

Same name and namespace in other branches
  1. 8.4 modules/features_ui/src/Form/FeaturesEditForm.php \Drupal\features_ui\Form\FeaturesEditForm::updateBundle()

Provides an ajax callback for handling switching the bundle selector.

File

modules/features_ui/src/Form/FeaturesEditForm.php, line 391

Class

FeaturesEditForm
Defines the features settings form.

Namespace

Drupal\features_ui\Form

Code

public function updateBundle($form, FormStateInterface $form_state) {
  $old_bundle = $this->assigner
    ->getBundle($this->oldBundle);
  $bundle_name = $form_state
    ->getValue('package');
  $bundle = $this->assigner
    ->getBundle($bundle_name);
  if (isset($bundle) && isset($old_bundle)) {
    $short_name = $old_bundle
      ->getShortName($this->package
      ->getMachineName());
    if ($bundle
      ->isDefault()) {
      $short_name = $old_bundle
        ->getFullName($short_name);
    }
    $this->package
      ->setMachineName($bundle
      ->getFullName($short_name));
    $form['info']['machine_name']['#value'] = $bundle
      ->getShortName($this->package
      ->getMachineName());
  }
  return $form['info'];
}