You are here

protected function InPlaceUpdate::getFilesList in Automatic Updates 8

Provide a recursive list of files, excluding directories.

Parameters

string $directory: The directory to recurse for files.

Return value

\RecursiveIteratorIterator|\SplFileInfo[] The iterator of SplFileInfos.

2 calls to InPlaceUpdate::getFilesList()
InPlaceUpdate::processUpdate in src/Services/InPlaceUpdate.php
Process update.
InPlaceUpdate::rollback in src/Services/InPlaceUpdate.php
Rollback after a failed update.

File

src/Services/InPlaceUpdate.php, line 505

Class

InPlaceUpdate
Class to apply in-place updates.

Namespace

Drupal\automatic_updates\Services

Code

protected function getFilesList($directory) {
  $filter = static function ($file, $file_name, $iterator) {

    /** @var \SplFileInfo $file */

    /** @var string $file_name */

    /** @var \RecursiveDirectoryIterator $iterator */
    if ($iterator
      ->hasChildren() && $file
      ->getFilename() !== '.git') {
      return TRUE;
    }
    $skipped_files = [
      self::DELETION_MANIFEST,
    ];
    return $file
      ->isFile() && !in_array($file
      ->getFilename(), $skipped_files, TRUE);
  };
  $innerIterator = new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS);
  return new \RecursiveIteratorIterator(new \RecursiveCallbackFilterIterator($innerIterator, $filter));
}