public function FeaturesGenerationMethodBase::prepare in Features 8.3
Same name and namespace in other branches
- 8.4 src/FeaturesGenerationMethodBase.php \Drupal\features\FeaturesGenerationMethodBase::prepare()
Prepares packages for generation.
Parameters
array $packages: Array of package data.
\Drupal\features\FeaturesBundleInterface $bundle: The optional bundle used for the generation. Used to generate profiles.
Return value
array An array of packages data.
Overrides FeaturesGenerationMethodInterface::prepare
File
- src/
FeaturesGenerationMethodBase.php, line 77
Class
- FeaturesGenerationMethodBase
- Base class for package assignment methods.
Namespace
Drupal\featuresCode
public function prepare(array &$packages = [], 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);
}