You are here

public function FeaturesManager::getExportInfo in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/FeaturesManager.php \Drupal\features\FeaturesManager::getExportInfo()

Returns the full machine name and directory for exporting a package.

Parameters

\Drupal\features\Package $package: The package.

\Drupal\features\FeaturesBundleInterface $bundle: Optional bundle being used for export.

Return value

array An array with the full name as the first item and directory as second item.

Overrides FeaturesManagerInterface::getExportInfo

File

src/FeaturesManager.php, line 1258

Class

FeaturesManager
The FeaturesManager provides helper functions for building packages.

Namespace

Drupal\features

Code

public function getExportInfo(Package $package, FeaturesBundleInterface $bundle = NULL) {
  $full_name = isset($bundle) ? $bundle
    ->getFullName($package
    ->getMachineName()) : $package
    ->getMachineName();
  $path = '';

  // Adjust export directory to be in profile.
  if (isset($bundle) && $bundle
    ->isProfile()) {
    $path .= 'profiles/' . $bundle
      ->getProfileName();
  }

  // If this is not the profile package, nest the directory.
  if (!isset($bundle) || !$bundle
    ->isProfilePackage($package
    ->getMachineName())) {
    $path .= empty($path) ? 'modules' : '/modules';
    $export_settings = $this
      ->getExportSettings();
    if (!empty($export_settings['folder'])) {
      $path .= '/' . $export_settings['folder'];
    }
  }

  // Use the same path of a package to override it.
  if ($extension = $package
    ->getExtension()) {
    $extension_path = $extension
      ->getPath();
    $path = dirname($extension_path);
  }
  return [
    $full_name,
    $path,
  ];
}