MediaWiki  master
SimpleCallbacks.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
17 class SimpleCallbacks implements Callbacks {
18 
20  private $params;
21 
23  private $files;
24 
26  private $conditions = [];
27 
32  public function __construct( array $params, array $files = [] ) {
33  $this->params = $params;
34  $this->files = $files;
35  }
36 
37  public function hasParam( $name, array $options ) {
38  return isset( $this->params[$name] );
39  }
40 
41  public function getValue( $name, $default, array $options ) {
42  return $this->params[$name] ?? $default;
43  }
44 
45  public function hasUpload( $name, array $options ) {
46  return isset( $this->files[$name] );
47  }
48 
49  public function getUploadedFile( $name, array $options ) {
50  $file = $this->files[$name] ?? null;
51  if ( $file && !$file instanceof UploadedFile ) {
52  $file = new UploadedFile( $file );
53  $this->files[$name] = $file;
54  }
55  // @phan-suppress-next-line PhanTypeMismatchReturnNullable False positive
56  return $file;
57  }
58 
59  public function recordCondition(
60  DataMessageValue $message, $name, $value, array $settings, array $options
61  ) {
62  $this->conditions[] = [
63  'message' => $message,
64  'name' => $name,
65  'value' => $value,
66  'settings' => $settings,
67  ];
68  }
69 
74  public function getRecordedConditions() {
75  return $this->conditions;
76  }
77 
81  public function clearRecordedConditions() {
82  $this->conditions = [];
83  }
84 
85  public function useHighLimits( array $options ) {
86  return !empty( $options['useHighLimits'] );
87  }
88 
89 }
Value object representing a message for i18n with alternative machine-readable data.
Simple Callbacks implementation for $_GET/$_POST/$_FILES data.
__construct(array $params, array $files=[])
useHighLimits(array $options)
Indicate whether "high limits" should be used.
recordCondition(DataMessageValue $message, $name, $value, array $settings, array $options)
Record non-fatal conditions.
hasParam( $name, array $options)
Test if a parameter exists in the request.
getUploadedFile( $name, array $options)
Fetch data for a file upload.
getValue( $name, $default, array $options)
Fetch a value from the request.
clearRecordedConditions()
Clear any recorded conditions.
getRecordedConditions()
Fetch any recorded conditions.
hasUpload( $name, array $options)
Test if a parameter exists as an upload in the request.
A simple implementation of UploadedFileInterface.
Interface defining callbacks needed by ParamValidator.
Definition: Callbacks.php:21
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42