You are here

protected function FeaturesManager::addPackageFiles in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/FeaturesManager.php \Drupal\features\FeaturesManager::addPackageFiles()

Generates and adds files to a given package or profile.

1 call to FeaturesManager::addPackageFiles()
FeaturesManager::prepareFiles in src/FeaturesManager.php
Iterates through packages and prepares file names and contents.

File

src/FeaturesManager.php, line 1025

Class

FeaturesManager
The FeaturesManager provides helper functions for building packages.

Namespace

Drupal\features

Code

protected function addPackageFiles(Package $package) {
  $config_collection = $this
    ->getConfigCollection();

  // Always add .info.yml and .features.yml files.
  $this
    ->addInfoFile($package);

  // Only add files if there is at least one piece of configuration present.
  if ($package
    ->getConfig()) {

    // Add configuration files.
    foreach ($package
      ->getConfig() as $name) {
      $config = $config_collection[$name];
      $package
        ->appendFile([
        'filename' => $config
          ->getName() . '.yml',
        'subdirectory' => $config
          ->getSubdirectory(),
        'string' => Yaml::encode($config
          ->getData()),
      ], $name);
    }
  }
}