path = $path; $this->localBasePath = $localBasePath; $this->remoteBasePath = $remoteBasePath; } /** * @return string * @throws RuntimeException If the base path was not provided. You must either provide the base * path in the constructor, or use getPath() instead and add the base path from a FileModule. */ public function getLocalPath(): string { if ( $this->localBasePath === null ) { throw new RuntimeException( 'Base path was not provided' ); } return "{$this->localBasePath}/{$this->path}"; } /** * @return string * @throws RuntimeException If the base path was not provided. You must either provide the base * path in the constructor, or use getPath() instead and add the base path from a FileModule. */ public function getRemotePath(): string { if ( $this->remoteBasePath === null ) { throw new RuntimeException( 'Base path was not provided' ); } if ( $this->remoteBasePath === '/' ) { // In document root // Don't insert another slash (T284391). return $this->remoteBasePath . $this->path; } return "{$this->remoteBasePath}/{$this->path}"; } /** @return string|null */ public function getLocalBasePath(): ?string { return $this->localBasePath; } /** @return string|null */ public function getRemoteBasePath(): ?string { return $this->remoteBasePath; } /** @return string */ public function getPath(): string { return $this->path; } /** * Set the base path if it has not already been set. * * @param string $localBasePath * @param string $remoteBasePath */ public function initBasePaths( string $localBasePath, string $remoteBasePath ) { if ( $this->localBasePath === null ) { $this->localBasePath = $localBasePath; } if ( $this->remoteBasePath === null ) { $this->remoteBasePath = $remoteBasePath; } } }