You are here

protected function FeaturesGenerationWrite::generatePackage in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/FeaturesGeneration/FeaturesGenerationWrite.php \Drupal\features\Plugin\FeaturesGeneration\FeaturesGenerationWrite::generatePackage()

Writes a package or profile's files to the file system.

Parameters

array &$return: The return value, passed by reference.

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

1 call to FeaturesGenerationWrite::generatePackage()
FeaturesGenerationWrite::generate in src/Plugin/FeaturesGeneration/FeaturesGenerationWrite.php
Performs package generation.

File

src/Plugin/FeaturesGeneration/FeaturesGenerationWrite.php, line 141

Class

FeaturesGenerationWrite
Class for writing packages to the local file system.

Namespace

Drupal\features\Plugin\FeaturesGeneration

Code

protected function generatePackage(array &$return, Package $package) {
  if (!$package
    ->getFiles()) {
    $this
      ->failure($return, $package, NULL, $this
      ->t('No configuration was selected to be exported.'));
    return;
  }
  $success = TRUE;
  foreach ($package
    ->getFiles() as $file) {
    try {
      $this
        ->generateFile($package
        ->getDirectory(), $file);
    } catch (\Exception $exception) {
      $this
        ->failure($return, $package, $exception);
      $success = FALSE;
      break;
    }
  }
  if ($success) {
    $this
      ->success($return, $package);
  }
}