MediaWiki REL1_37
SimpleCallbacks.php
Go to the documentation of this file.
1<?php
2
4
7
17class 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 return $file;
56 }
57
58 public function recordCondition(
59 DataMessageValue $message, $name, $value, array $settings, array $options
60 ) {
61 $this->conditions[] = [
62 'message' => $message,
63 'name' => $name,
64 'value' => $value,
65 'settings' => $settings,
66 ];
67 }
68
73 public function getRecordedConditions() {
74 return $this->conditions;
75 }
76
80 public function clearRecordedConditions() {
81 $this->conditions = [];
82 }
83
84 public function useHighLimits( array $options ) {
85 return !empty( $options['useHighLimits'] );
86 }
87
88}
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=[])
array[] $conditions
Any recorded conditions.
string string[][] $params
$_GET/$_POST data
array UploadedFile[] $files
$_FILES data or UploadedFile instances
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