MediaWiki REL1_40
DerivativeRequest.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Request;
27
28use 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
107class_alias( DerivativeRequest::class, 'DerivativeRequest' );
Similar to MediaWiki\Request\FauxRequest, but only fakes URL parameters and method (POST or GET) and ...
getHeader( $name, $flags=0)
Get a request header, or false if it isn't set.
__construct(WebRequest $base, $data, $wasPosted=false)
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
getAcceptLang()
Parse the Accept-Language header sent by the client into an array.
getSessionData( $key)
Get data from the session.
getElapsedTime()
Get the number of seconds to have elapsed since request start, in fractional seconds,...
getProtocol()
Get the current URL protocol (http or https)
getIP()
Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of...
getUpload( $key)
Return a MediaWiki\Request\FauxRequestUpload object corresponding to the key.
getSession()
Return the session for this request.
getAllHeaders()
Get an array containing all request headers.
WebRequest clone which takes values from a provided array.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
array $data
The parameters from $_GET, $_POST and the path router.