protected function FeaturesManager::getPackageObject in Features 8.4
Same name and namespace in other branches
- 8.3 src/FeaturesManager.php \Drupal\features\FeaturesManager::getPackageObject()
Initializes and returns a package or profile array.
Parameters
string $machine_name: Machine name of the package.
string $name: (optional) Human readable name of the package.
string $description: (optional) Description of the package.
string $type: (optional) Type of project.
\Drupal\features\FeaturesBundleInterface $bundle: (optional) Bundle to use to add profile directories to the scan.
\Drupal\Core\Extension\Extension $extension: (optional) An Extension object.
Return value
\Drupal\features\Package An array of package properties; see FeaturesManagerInterface::getPackages().
1 call to FeaturesManager::getPackageObject()
- FeaturesManager::initPackage in src/
FeaturesManager.php - Initializes a configuration package.
File
- src/
FeaturesManager.php, line 879
Class
- FeaturesManager
- The FeaturesManager provides helper functions for building packages.
Namespace
Drupal\featuresCode
protected function getPackageObject($machine_name, $name = NULL, $description = '', $type = 'module', FeaturesBundleInterface $bundle = NULL, Extension $extension = NULL) {
if (!isset($bundle)) {
$bundle = $this
->getAssigner()
->getBundle();
}
$package = new Package($machine_name, [
'name' => isset($name) ? $name : ucwords(str_replace([
'_',
'-',
], ' ', $machine_name)),
'description' => $description,
'type' => $type,
'status' => FeaturesManagerInterface::STATUS_DEFAULT,
'state' => FeaturesManagerInterface::STATE_DEFAULT,
'bundle' => $bundle
->isDefault() ? '' : $bundle
->getMachineName(),
]);
// If no extension was passed in, look for a match.
if (!isset($extension)) {
$module_list = $this
->getFeaturesModules($bundle);
$module_name = $package
->getMachineName();
if (isset($module_list[$module_name])) {
$extension = $module_list[$module_name];
}
}
// If there is an extension, set extension-specific properties.
if (isset($extension)) {
$info = $this
->getExtensionInfo($extension);
$features_info = $this
->getFeaturesInfo($extension);
$package
->setExtension($extension);
$package
->setInfo($info);
$package
->setFeaturesInfo($features_info);
$package
->setConfigOrig($this
->listExtensionConfig($extension));
$package
->setStatus($this
->extensionEnabled($extension) ? FeaturesManagerInterface::STATUS_INSTALLED : FeaturesManagerInterface::STATUS_UNINSTALLED);
$package
->setVersion(isset($info['version']) ? $info['version'] : '');
}
return $package;
}