You are here

public function ScaffoldFileCollection::filterFiles in Drupal 9

Same name and namespace in other branches
  1. 8 composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php \Drupal\Composer\Plugin\Scaffold\Operations\ScaffoldFileCollection::filterFiles()

Removes any item that has a path matching any path in the provided list.

Matching is done via destination path.

Parameters

string[] $files_to_filter: List of destination paths

File

composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php, line 82

Class

ScaffoldFileCollection
Collection of scaffold files.

Namespace

Drupal\Composer\Plugin\Scaffold\Operations

Code

public function filterFiles(array $files_to_filter) {
  foreach ($this->scaffoldFilesByProject as $project_name => $scaffold_files) {
    foreach ($scaffold_files as $destination_rel_path => $scaffold_file) {
      if (in_array($destination_rel_path, $files_to_filter, TRUE)) {
        unset($scaffold_files[$destination_rel_path]);
      }
    }
    $this->scaffoldFilesByProject[$project_name] = $scaffold_files;
    if (!$this
      ->checkListHasItemWithContent($scaffold_files)) {
      unset($this->scaffoldFilesByProject[$project_name]);
    }
  }
}