MediaWiki  1.34.0
FileSystemFetcher.php
Go to the documentation of this file.
1 <?php
8 namespace LocalisationUpdate;
9 
13 class FileSystemFetcher implements Fetcher {
19  public function fetchFile( $url ) {
20  // Remove the protocol prefix
21  $url = preg_replace( '~^file://~', '', $url );
22 
23  if ( !is_readable( $url ) ) {
24  return false;
25  }
26 
27  return file_get_contents( $url );
28  }
29 
35  public function fetchDirectory( $pattern ) {
36  // Remove the protocol prefix
37  $pattern = preg_replace( '~^file://~', '', $pattern );
38 
39  $data = [];
40  foreach ( glob( $pattern ) as $file ) {
41  if ( is_readable( $file ) ) {
42  $data["file://$file"] = file_get_contents( $file );
43  }
44  }
45  return $data;
46  }
47 }
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
LocalisationUpdate\FileSystemFetcher
Accesses file system directly.
Definition: FileSystemFetcher.php:13
LocalisationUpdate\FileSystemFetcher\fetchDirectory
fetchDirectory( $pattern)
Definition: FileSystemFetcher.php:35
LocalisationUpdate
Definition: Fetcher.php:8
LocalisationUpdate\FileSystemFetcher\fetchFile
fetchFile( $url)
Definition: FileSystemFetcher.php:19
LocalisationUpdate\Fetcher
Interface for classes which fetch files over different protocols and ways.
Definition: Fetcher.php:13