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
141 self::PARAM_SOURCE =>
'path',
142 ParamValidator::PARAM_TYPE =>
'string',
143 ParamValidator::PARAM_REQUIRED =>
true,
158 return '"' .
$file->getSha1() .
'"';
171 return $file->getTimestamp();
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...
Prioritized list of file repositories.
Service for looking up information about wiki pages.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.