/**
   * {@inheritdoc}
   */
  public function prepare(array &$packages = array(), FeaturesBundleInterface $bundle = NULL) {
    // If no packages were specified, get all packages.
    if (empty($packages)) {
      $packages = $this->featuresManager->getPackages();
    }

    // If any packages exist, read in their files.
    $existing_packages = $this->featuresManager->listPackageDirectories(array_keys($packages), $bundle);

    foreach ($packages as &$package) {
      list($full_name, $path) = $this->featuresManager->getExportInfo($package, $bundle);
      $package['directory'] = $path . '/' . $full_name;
      $this->preparePackage($package, $existing_packages, $bundle);
    }
    // Clean up the $package pass by reference.
    unset($package);

    if (isset($bundle) && $bundle->isProfile()) {
      $profile_name = $bundle->getProfileName();
      $profile_package = $this->featuresManager->getPackage($profile_name);
      if (isset($profile_package)) {
        $package['directory'] = 'profiles/' . $profile_name;
        $this->preparePackage($profile_package, $existing_packages, $bundle);
      }
    }
  }
 /**
  * {@inheritdoc}
  */
 public function prepare(array &$packages = array(), FeaturesBundleInterface $bundle = NULL)
 {
     // If no packages were specified, get all packages.
     if (empty($packages)) {
         $packages = $this->featuresManager->getPackages();
     }
     // If any packages exist, read in their files.
     $existing_packages = $this->featuresManager->listPackageDirectories(array_keys($packages), $bundle);
     foreach ($packages as &$package) {
         list($full_name, $path) = $this->featuresManager->getExportInfo($package, $bundle);
         if (empty($package->getDirectory())) {
             $package->setDirectory($path);
         }
         // If this is the profile, its directory is already assigned.
         if (!isset($bundle) || !$bundle->isProfilePackage($package->getMachineName())) {
             $current_path = $package->getDirectory();
             if (strpos($current_path, $full_name) < strlen($current_path) - strlen($full_name)) {
                 // Only append package name if it isn't already there.
                 $package->setDirectory($package->getDirectory() . '/' . $full_name);
             }
         }
         $this->preparePackage($package, $existing_packages, $bundle);
     }
     // Clean up the $package pass by reference.
     unset($package);
 }
 /**
  * {@inheritdoc}
  */
 public function prepare(array &$packages = array(), FeaturesBundleInterface $bundle = NULL)
 {
     // If no packages were specified, get all packages.
     if (empty($packages)) {
         $packages = $this->featuresManager->getPackages();
     }
     // If any packages exist, read in their files.
     $existing_packages = $this->featuresManager->listPackageDirectories(array_keys($packages), $bundle);
     foreach ($packages as &$package) {
         list($full_name, $path) = $this->featuresManager->getExportInfo($package, $bundle);
         $package['directory'] = $path;
         // If this is the profile, its directory is already assigned.
         if (!isset($bundle) || !$bundle->isProfilePackage($package['machine_name'])) {
             $package['directory'] .= '/' . $full_name;
         }
         $this->preparePackage($package, $existing_packages, $bundle);
     }
     // Clean up the $package pass by reference.
     unset($package);
 }