MediaWiki  master
DerivativeRequest.php
Go to the documentation of this file.
1 <?php
27 
28 use WebRequest;
29 
41  private $base;
42  private $ip;
43 
52  public function __construct( WebRequest $base, $data, $wasPosted = false ) {
53  $this->base = $base;
54  parent::__construct( $data, $wasPosted );
55  }
56 
57  public function getCookie( $key, $prefix = null, $default = null ) {
58  return $this->base->getCookie( $key, $prefix, $default );
59  }
60 
61  public function getHeader( $name, $flags = 0 ) {
62  return $this->base->getHeader( $name, $flags );
63  }
64 
65  public function getAllHeaders() {
66  return $this->base->getAllHeaders();
67  }
68 
69  public function getSession() {
70  return $this->base->getSession();
71  }
72 
73  public function getSessionData( $key ) {
74  return $this->base->getSessionData( $key );
75  }
76 
77  public function setSessionData( $key, $data ) {
78  $this->base->setSessionData( $key, $data );
79  }
80 
81  public function getAcceptLang() {
82  return $this->base->getAcceptLang();
83  }
84 
85  public function getIP() {
86  return $this->ip ?: $this->base->getIP();
87  }
88 
89  public function setIP( $ip ) {
90  $this->ip = $ip;
91  }
92 
93  public function getProtocol() {
94  return $this->base->getProtocol();
95  }
96 
97  public function getUpload( $key ) {
98  // @phan-suppress-next-line PhanTypeMismatchReturnSuperType
99  return $this->base->getUpload( $key );
100  }
101 
102  public function getElapsedTime() {
103  return $this->base->getElapsedTime();
104  }
105 }
106 
107 class_alias( DerivativeRequest::class, 'DerivativeRequest' );
Similar to MediaWiki\Request\FauxRequest, but only fakes URL parameters and method (POST or GET) and ...
getAllHeaders()
Get an array containing all request headers.
getUpload( $key)
Return a MediaWiki\Request\FauxRequestUpload object corresponding to the key.
getSessionData( $key)
Get data from the session.
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
getElapsedTime()
Get the number of seconds to have elapsed since request start, in fractional seconds,...
getHeader( $name, $flags=0)
Get a request header, or false if it isn't set.
__construct(WebRequest $base, $data, $wasPosted=false)
getIP()
Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of...
getSession()
Return the session for this request.
getAcceptLang()
Parse the Accept-Language header sent by the client into an array.
getProtocol()
Get the current URL protocol (http or https)
WebRequest clone which takes values from a provided array.
Definition: FauxRequest.php:42
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:47
array $data
The parameters from $_GET, $_POST and the path router.
Definition: WebRequest.php:52