5 use Drupal\Core\File\FileSystemInterface;
18 return \Drupal::service(
'file_system')
25 public function prepareDir(&$directory, $options = FileSystemInterface::CREATE_DIRECTORY) {
26 return \Drupal::service(
'file_system')->prepareDirectory($directory, $options);
32 public function retrieveFile($url, $destination = NULL, $managed = FALSE) {
33 if (substr_count($url,
"file://") > 0) {
35 $src = str_replace(
"file://",
"", $url);
37 $pieces = parse_url($url);
38 $path = explode(
"/", $pieces[
'path']);
39 $filename = end($path);
41 $dest = $this->
getRealPath($destination) .
"/{$filename}";
45 $url = file_create_url(
"{$destination}/{$filename}");
50 return system_retrieve_file($url, $destination, $managed, FileSystemInterface::EXISTS_REPLACE);
58 return file_create_url($uri);
68 \Drupal::config(
'system.file')
69 ->
get(
'default_scheme') .
"://"
77 return (is_readable($path) && is_file($path))
78 ? file_get_contents($path)
86 return file_put_contents($path, $content);
93 if (file_exists($uri)) {
102 return glob($pattern, $flags);