MediaWiki REL1_39
FilePath.php
Go to the documentation of this file.
1<?php
22
23use RuntimeException;
24
34class FilePath {
36 protected $localBasePath;
37
39 protected $remoteBasePath;
40
42 protected $path;
43
50 public function __construct( $path, $localBasePath = null, $remoteBasePath = null ) {
51 $this->path = $path;
52 $this->localBasePath = $localBasePath;
53 $this->remoteBasePath = $remoteBasePath;
54 }
55
61 public function getLocalPath() {
62 if ( $this->localBasePath === null ) {
63 throw new RuntimeException( 'Base path was not provided' );
64 }
65 return "{$this->localBasePath}/{$this->path}";
66 }
67
73 public function getRemotePath() {
74 if ( $this->remoteBasePath === null ) {
75 throw new RuntimeException( 'Base path was not provided' );
76 }
77 if ( $this->remoteBasePath === '/' ) {
78 // In document root
79 // Don't insert another slash (T284391).
80 return $this->remoteBasePath . $this->path;
81 }
82 return "{$this->remoteBasePath}/{$this->path}";
83 }
84
86 public function getLocalBasePath() {
88 }
89
91 public function getRemoteBasePath() {
93 }
94
96 public function getPath() {
97 return $this->path;
98 }
99}
100
102class_alias( FilePath::class, 'ResourceLoaderFilePath' );
A path to a bundled file (such as JavaScript or CSS), along with a remote and local base path.
Definition FilePath.php:34
__construct( $path, $localBasePath=null, $remoteBasePath=null)
Definition FilePath.php:50
string null $remoteBasePath
Remote base path.
Definition FilePath.php:39
string null $localBasePath
Local base path.
Definition FilePath.php:36
string $path
Path to the file.
Definition FilePath.php:42