31 private $page =
false;
36 private $file =
false;
46 $this->repoGroup = $repoGroup;
47 $this->pageLookup = $pageLookup;
54 if ( $this->page === false ) {
55 $this->page = $this->pageLookup->getExistingPageByText(
65 private function getFile(): ?File {
66 if ( $this->file === false ) {
67 $page = $this->getPage();
70 $this->repoGroup->findFile( $page, [
'private' => $this->
getAuthority() ] ) ?:
null;
80 public function run( $title ) {
81 $page = $this->getPage();
85 MessageValue::new(
'rest-nonexistent-title' )->plaintextParams( $title ),
90 if ( !$this->
getAuthority()->authorizeRead(
'read', $page ) ) {
92 MessageValue::new(
'rest-permission-denied-title' )->plaintextParams( $title ),
98 if ( !$fileObj || !$fileObj->exists() ) {
100 MessageValue::new(
'rest-cannot-load-file' )->plaintextParams( $title ),
105 $response = $this->getResponse( $fileObj );
106 return $this->getResponseFactory()->createJson( $response );
113 private function getResponse(
File $file ): array {
114 [ $maxWidth, $maxHeight ] = self::getImageLimitsFromOption(
117 [ $maxThumbWidth, $maxThumbHeight ] = self::getImageLimitsFromOption(
122 'maxWidth' => $maxWidth,
123 'maxHeight' => $maxHeight
126 'maxWidth' => $maxThumbWidth,
127 'maxHeight' => $maxThumbHeight
131 return $this->getFileInfo( $file, $this->
getAuthority(), $transforms );
141 self::PARAM_SOURCE =>
'path',
142 ParamValidator::PARAM_TYPE =>
'string',
143 ParamValidator::PARAM_REQUIRED =>
true,
154 if ( !$file || !$file->
exists() ) {
158 return '"' . $file->
getSha1() .
'"';
167 if ( !$file || !$file->
exists() ) {
179 return $file && $file->
exists();
getFile()
Get the file for this page, if one exists.
if(!defined('MW_SETUP_CALLBACK'))
Implements some public methods and some protected utility functions which are required by multiple ch...
getTimestamp()
Get the 14-character timestamp of the file upload.
exists()
Returns true if file exists in the repository.
getSha1()
Get the SHA-1 base 36 hash of the file.
Prioritized list of file repositories.
Service for looking up information about wiki pages.