public function FeaturesGenerationWrite::generate in Features 8.4
Same name and namespace in other branches
- 8.3 src/Plugin/FeaturesGeneration/FeaturesGenerationWrite.php \Drupal\features\Plugin\FeaturesGeneration\FeaturesGenerationWrite::generate()
Performs package 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 Array of results for profile and/or packages, each result including the following keys:
- 'success': boolean TRUE or FALSE for successful writing.
- 'display': boolean TRUE if the message should be displayed to the user, otherwise FALSE.
- 'message': a message about the result of the operation.
- 'variables': an array of substitutions to be used in the message.
Overrides FeaturesGenerationMethodInterface::generate
File
- src/
Plugin/ FeaturesGeneration/ FeaturesGenerationWrite.php, line 107
Class
- FeaturesGenerationWrite
- Class for writing packages to the local file system.
Namespace
Drupal\features\Plugin\FeaturesGenerationCode
public function generate(array $packages = [], FeaturesBundleInterface $bundle = NULL) {
// If no packages were specified, get all packages.
if (empty($packages)) {
$packages = $this->featuresManager
->getPackages();
}
$return = [];
// Add package files.
// We need to update the system.module.files state because it's cached.
// Cannot just call system_rebuild_module_data() because $listing->scan()
// has it's own internal static cache that we cannot clear at this point.
$files = \Drupal::state()
->get('system.module.files');
foreach ($packages as $package) {
$this
->generatePackage($return, $package);
if (!isset($files[$package
->getMachineName()]) && isset($package
->getFiles()['info'])) {
$files[$package
->getMachineName()] = $package
->getDirectory() . '/' . $package
->getFiles()['info']['filename'];
}
}
// Rebuild system module cache.
\Drupal::state()
->set('system.module.files', $files);
return $return;
}