You are here

public static function SampleDataLoader::getFile in YAML Content 8.2

Helper function to retrieve files.

Parameters

string $file_path: File destination path.

string $file_src: File source path.

Return value

\Drupal\file\FileInterface|false A file entity, or FALSE on error.

2 calls to SampleDataLoader::getFile()
SampleDataLoader::getThemeFile in modules/sample_data/src/SampleDataLoader.php
Helper function for theme images.
SampleDataLoader::loadSample in modules/sample_data/src/SampleDataLoader.php
Load sample data based on type and additional parameters.

File

modules/sample_data/src/SampleDataLoader.php, line 149

Class

SampleDataLoader
Provides methods for retrieving sample data to be used in demo content.

Namespace

Drupal\sample_data

Code

public static function getFile($file_path, $file_src) {
  $file = file_get_contents($file_src);
  $destination = \Drupal::service('file_system')
    ->dirname("public://{$file_path}");
  file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
  return file_save_data($file, "public://{$file_path}", FILE_EXISTS_REPLACE);
}