Same name and namespace in other branches
  1. 10 core/modules/file/tests/file_test/file_test.module \file_test_file_scan_callback()
  2. 7.x modules/simpletest/tests/file.test \file_test_file_scan_callback()
  3. 9 core/modules/file/tests/file_test/file_test.module \file_test_file_scan_callback()

Helper function for testing FileSystemInterface::scanDirectory().

Each time the function is called the file is stored in a static variable. When the function is called with no $filepath parameter, the results are returned.

Parameters

string|null $filepath: File path

bool $reset: (optional) If to reset the internal memory cache. If TRUE is passed, the first parameter has no effect. Defaults to FALSE.

Return value

array If $filepath is NULL, an array of all previous $filepath parameters

2 calls to file_test_file_scan_callback()
file_test_file_scan_callback_reset in core/modules/file/tests/file_test/file_test.module
Reset static variables used by file_test_file_scan_callback().
ScanDirectoryTest::testOptionCallback in core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
Check that the callback function is called correctly.
1 string reference to 'file_test_file_scan_callback'
ScanDirectoryTest::testOptionCallback in core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
Check that the callback function is called correctly.

File

core/modules/file/tests/file_test/file_test.module, line 332
Helper module for the file tests.

Code

function file_test_file_scan_callback($filepath = NULL, $reset = FALSE) {
  static $files = [];
  if ($reset) {
    $files = [];
  }
  elseif ($filepath) {
    $files[] = $filepath;
  }
  return $files;
}