You are here

public function LoadHelper::discoverFiles in YAML Content 8

Scan and discover content files for import.

The scanner assumes all content files will follow the naming convention of '*.content.yml'.

Parameters

string $path: The directory path to be scanned for content files.

string $mask: (Optional) A file name mask to limit matches in scanned files.

Return value

array An associative array of objects keyed by filename with the following properties as returned by FileSystemInterface::scanDirectory():

  • 'uri'
  • 'filename'
  • 'name'

See also

\Drupal\Core\File\FileSystemInterface::scanDirectory()

3 calls to LoadHelper::discoverFiles()
LoadHelper::importDirectory in src/Service/LoadHelper.php
Import specified yaml content file(s).
LoadHelper::importModule in src/Service/LoadHelper.php
Import specified yaml content file(s) from a designated module.
LoadHelper::importProfile in src/Service/LoadHelper.php
Import specified yaml content file(s) from a designated profile.

File

src/Service/LoadHelper.php, line 142

Class

LoadHelper
A helper class to support the content loading process.

Namespace

Drupal\yaml_content\Service

Code

public function discoverFiles($path, $mask = '/.*\\.content\\.yml/') {

  // Identify files for import.
  $files = \Drupal::service('file_system')
    ->scanDirectory($path, $mask, [
    'key' => 'filename',
    'recurse' => FALSE,
  ]);

  // Sort the files to ensure consistent sequence during imports.
  ksort($files);
  return $files;
}