MediaWiki REL1_30
FileSystemFetcher.php
Go to the documentation of this file.
1<?php
8namespace LocalisationUpdate;
9
13class FileSystemFetcher implements Fetcher {
14 public function fetchFile( $url ) {
15 // Remove the protocol prefix
16 $url = preg_replace( '~^file://~', '', $url );
17
18 if ( !is_readable( $url ) ) {
19 return false;
20 }
21
22 return file_get_contents( $url );
23 }
24
25 public function fetchDirectory( $pattern ) {
26 // Remove the protocol prefix
27 $pattern = preg_replace( '~^file://~', '', $pattern );
28
29 $data = [];
30 foreach ( glob( $pattern ) as $file ) {
31 if ( is_readable( $file ) ) {
32 $data["file://$file"] = file_get_contents( $file );
33 }
34 }
35 return $data;
36 }
37}
Accesses file system directly.
fetchFile( $url)
Fetches a single resource.
fetchDirectory( $pattern)
Fetch a list of resources.
Interface for classes which fetch files over different protocols and ways.
Definition Fetcher.php:13