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