public function FeaturesManager::filterPackages in Features 8.3
Same name and namespace in other branches
- 8.4 src/FeaturesManager.php \Drupal\features\FeaturesManager::filterPackages()
Filters the supplied package list by the given namespace.
Parameters
\Drupal\features\Package[] $packages: An array of packages.
string $namespace: The namespace to use.
bool $only_exported: If true, only filter out packages that are exported.
Return value
\Drupal\features\Package[] An array of packages.
Overrides FeaturesManagerInterface::filterPackages
File
- src/
FeaturesManager.php, line 334
Class
- FeaturesManager
- The FeaturesManager provides helper functions for building packages.
Namespace
Drupal\featuresCode
public function filterPackages(array $packages, $namespace = '', $only_exported = FALSE) {
$result = [];
/** @var \Drupal\features\Package $package */
foreach ($packages as $key => $package) {
// A package matches the namespace if:
// - it's prefixed with the namespace, or
// - it's assigned to a bundle named for the namespace, or
// - the namespace is the default bundle and it has an empty bundle, and
// - we're not removing only exported packages, or
// - we are removing only exported packages and it's not exported.
if ((strpos($package
->getMachineName(), $namespace . '_') === 0 || $package
->getBundle() && $package
->getBundle() === $namespace || $namespace === FeaturesBundleInterface::DEFAULT_BUNDLE && empty($package
->getBundle())) && (!$only_exported || $package
->getStatus() === FeaturesManagerInterface::STATUS_NO_EXPORT)) {
$result[$key] = $package;
}
}
return $result;
}