You are here

protected function DirectoryDestination::getAllFileNames in Backup and Migrate 5.0.x

Get the entire file list from this destination.

Return value

array

2 calls to DirectoryDestination::getAllFileNames()
DirectoryDestination::countFiles in src/Core/Destination/DirectoryDestination.php
DirectoryDestination::listFiles in src/Core/Destination/DirectoryDestination.php
Return a list of files from the destination.

File

src/Core/Destination/DirectoryDestination.php, line 234

Class

DirectoryDestination
@package Drupal\backup_migrate\Core\Destination

Namespace

Drupal\backup_migrate\Core\Destination

Code

protected function getAllFileNames() {
  $files = [];

  // Read the list of files from the directory.
  $dir = $this
    ->confGet('directory');

  /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
  $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
  $scheme = $stream_wrapper_manager
    ->getScheme($dir);

  // Ensure the stream is configured.
  if (!$stream_wrapper_manager
    ->isValidScheme($scheme)) {
    \Drupal::messenger()
      ->addMessage($this
      ->t('Your @scheme stream is not configured.', [
      '@scheme' => $scheme . '://',
    ]), 'warning');
    return $files;
  }
  if ($handle = opendir($dir)) {
    while (FALSE !== ($file = readdir($handle))) {
      $filepath = $dir . '/' . $file;

      // Don't show hidden, unreadable or metadata files.
      if (substr($file, 0, 1) !== '.' && is_readable($filepath) && substr($file, strlen($file) - 5) !== '.info') {
        $files[] = $file;
      }
    }
  }
  return $files;
}