You are here

public function FeaturesAssigner::renameBundle in Features 8.4

Same name and namespace in other branches
  1. 8.3 src/FeaturesAssigner.php \Drupal\features\FeaturesAssigner::renameBundle()

Renames a bundle.

Parameters

string $old_machine: The old machine name of a bundle.

string $new_machine: The new machine name of a bundle.

Return value

\Drupal\features\FeaturesBundleInterface A features bundle object.

Overrides FeaturesAssignerInterface::renameBundle

File

src/FeaturesAssigner.php, line 410

Class

FeaturesAssigner
Class responsible for performing package assignment.

Namespace

Drupal\features

Code

public function renameBundle($old_machine, $new_machine) {
  $is_current = isset($this->currentBundle) && $old_machine == $this->currentBundle
    ->getMachineName();
  $bundle = $this
    ->getBundle($old_machine);
  if ($bundle
    ->getMachineName() != '') {

    // Remove old bundle from the list if it's not the Default bundle.
    unset($this->bundles[$old_machine]);
  }
  $bundle
    ->setMachineName($new_machine);
  $this
    ->setBundle($bundle);

  // Put the bundle into the list with the correct name.
  $this->bundles[$bundle
    ->getMachineName()] = $bundle;
  if ($is_current) {
    $this
      ->setCurrent($bundle);
  }
  return $bundle;
}