PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/event-espresso-decaf/core/request_stack/EE_Request.core.php

https://bitbucket.org/solidcode_bridge/bfm_learning_centre
PHP | 392 lines | 115 code | 65 blank | 212 comment | 2 complexity | 9206d63376ef765ed1644ac5b9f0cd61 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception, Apache-2.0, JSON
  1. <?php
  2. use EventEspresso\core\exceptions\InvalidDataTypeException;
  3. use EventEspresso\core\exceptions\InvalidInterfaceException;
  4. use EventEspresso\core\interfaces\InterminableInterface;
  5. use EventEspresso\core\services\loaders\LoaderFactory;
  6. use EventEspresso\core\services\request\LegacyRequestInterface;
  7. use EventEspresso\core\services\request\RequestInterface;
  8. defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
  9. /**
  10. * class EE_Request
  11. *
  12. * @deprecated 4.9.53
  13. * @package Event Espresso
  14. * @subpackage /core/
  15. * @author Brent Christensen
  16. */
  17. class EE_Request implements LegacyRequestInterface, InterminableInterface
  18. {
  19. /**
  20. * @var RequestInterface $request
  21. */
  22. private $request;
  23. /**
  24. * whether current request is for the admin but NOT via AJAX
  25. *
  26. * @var boolean $admin
  27. */
  28. public $admin = false;
  29. /**
  30. * whether current request is via AJAX
  31. *
  32. * @var boolean $ajax
  33. */
  34. public $ajax = false;
  35. /**
  36. * whether current request is via AJAX from the frontend of the site
  37. *
  38. * @var boolean $front_ajax
  39. */
  40. public $front_ajax = false;
  41. /**
  42. * @deprecated 4.9.53
  43. * @param array $get
  44. * @param array $post
  45. * @param array $cookie
  46. * @param array $server
  47. */
  48. public function __construct(
  49. array $get = array(),
  50. array $post = array(),
  51. array $cookie = array(),
  52. array $server = array()
  53. ) {
  54. }
  55. /**
  56. * @return RequestInterface
  57. * @throws InvalidArgumentException
  58. * @throws InvalidInterfaceException
  59. * @throws InvalidDataTypeException
  60. */
  61. private function request()
  62. {
  63. if($this->request instanceof RequestInterface){
  64. return $this->request;
  65. }
  66. $loader = LoaderFactory::getLoader();
  67. $this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface');
  68. return $this->request;
  69. }
  70. /**
  71. * @param RequestInterface $request
  72. */
  73. public function setRequest(RequestInterface $request)
  74. {
  75. $this->request = $request;
  76. }
  77. /**
  78. * @deprecated 4.9.53
  79. * @return array
  80. * @throws InvalidArgumentException
  81. * @throws InvalidDataTypeException
  82. * @throws InvalidInterfaceException
  83. */
  84. public function get_params()
  85. {
  86. return $this->request()->getParams();
  87. }
  88. /**
  89. * @deprecated 4.9.53
  90. * @return array
  91. * @throws InvalidArgumentException
  92. * @throws InvalidDataTypeException
  93. * @throws InvalidInterfaceException
  94. */
  95. public function post_params()
  96. {
  97. return $this->request()->postParams();
  98. }
  99. /**
  100. * @deprecated 4.9.53
  101. * @return array
  102. * @throws InvalidArgumentException
  103. * @throws InvalidDataTypeException
  104. * @throws InvalidInterfaceException
  105. */
  106. public function cookie_params()
  107. {
  108. return $this->request()->cookieParams();
  109. }
  110. /**
  111. * @deprecated 4.9.53
  112. * @return array
  113. * @throws InvalidArgumentException
  114. * @throws InvalidDataTypeException
  115. * @throws InvalidInterfaceException
  116. */
  117. public function server_params()
  118. {
  119. return $this->request()->serverParams();
  120. }
  121. /**
  122. * returns contents of $_REQUEST
  123. *
  124. * @deprecated 4.9.53
  125. * @return array
  126. * @throws InvalidArgumentException
  127. * @throws InvalidDataTypeException
  128. * @throws InvalidInterfaceException
  129. */
  130. public function params()
  131. {
  132. return $this->request()->requestParams();
  133. }
  134. /**
  135. * @deprecated 4.9.53
  136. * @param $key
  137. * @param $value
  138. * @param bool $override_ee
  139. * @return void
  140. * @throws InvalidArgumentException
  141. * @throws InvalidDataTypeException
  142. * @throws InvalidInterfaceException
  143. */
  144. public function set($key, $value, $override_ee = false)
  145. {
  146. $this->request()->setRequestParam($key, $value, $override_ee);
  147. }
  148. /**
  149. * returns the value for a request param if the given key exists
  150. *
  151. * @deprecated 4.9.53
  152. * @param $key
  153. * @param null $default
  154. * @return mixed
  155. * @throws InvalidArgumentException
  156. * @throws InvalidDataTypeException
  157. * @throws InvalidInterfaceException
  158. */
  159. public function get($key, $default = null)
  160. {
  161. return $this->request()->getRequestParam($key, $default);
  162. }
  163. /**
  164. * check if param exists
  165. *
  166. * @deprecated 4.9.53
  167. * @param $key
  168. * @return bool
  169. * @throws InvalidArgumentException
  170. * @throws InvalidDataTypeException
  171. * @throws InvalidInterfaceException
  172. */
  173. public function is_set($key)
  174. {
  175. return $this->request()->requestParamIsSet($key);
  176. }
  177. /**
  178. * remove param
  179. *
  180. * @deprecated 4.9.53
  181. * @param $key
  182. * @param bool $unset_from_global_too
  183. * @throws InvalidArgumentException
  184. * @throws InvalidDataTypeException
  185. * @throws InvalidInterfaceException
  186. */
  187. public function un_set($key, $unset_from_global_too = false)
  188. {
  189. $this->request()->unSetRequestParam($key, $unset_from_global_too);
  190. }
  191. /**
  192. * @deprecated 4.9.53
  193. * @return string
  194. * @throws InvalidArgumentException
  195. * @throws InvalidDataTypeException
  196. * @throws InvalidInterfaceException
  197. */
  198. public function ip_address()
  199. {
  200. return $this->request()->ipAddress();
  201. }
  202. /**
  203. * @deprecated 4.9.53
  204. * @return bool
  205. * @throws InvalidArgumentException
  206. * @throws InvalidDataTypeException
  207. * @throws InvalidInterfaceException
  208. */
  209. public function isAdmin()
  210. {
  211. return $this->request()->isAdmin();
  212. }
  213. /**
  214. * @deprecated 4.9.53
  215. * @return mixed
  216. * @throws InvalidArgumentException
  217. * @throws InvalidDataTypeException
  218. * @throws InvalidInterfaceException
  219. */
  220. public function isAjax()
  221. {
  222. return $this->request()->isAjax();
  223. }
  224. /**
  225. * @deprecated 4.9.53
  226. * @return mixed
  227. * @throws InvalidArgumentException
  228. * @throws InvalidDataTypeException
  229. * @throws InvalidInterfaceException
  230. */
  231. public function isFrontAjax()
  232. {
  233. return $this->request()->isFrontAjax();
  234. }
  235. /**
  236. * @deprecated 4.9.53
  237. * @return mixed|string
  238. * @throws InvalidArgumentException
  239. * @throws InvalidDataTypeException
  240. * @throws InvalidInterfaceException
  241. */
  242. public function requestUri()
  243. {
  244. return $this->request()->requestUri();
  245. }
  246. /**
  247. * @deprecated 4.9.53
  248. * @return string
  249. * @throws InvalidArgumentException
  250. * @throws InvalidDataTypeException
  251. * @throws InvalidInterfaceException
  252. */
  253. public function userAgent()
  254. {
  255. return $this->request()->userAgent();
  256. }
  257. /**
  258. * @deprecated 4.9.53
  259. * @param string $user_agent
  260. * @throws InvalidArgumentException
  261. * @throws InvalidDataTypeException
  262. * @throws InvalidInterfaceException
  263. */
  264. public function setUserAgent($user_agent = '')
  265. {
  266. $this->request()->setUserAgent($user_agent);
  267. }
  268. /**
  269. * @deprecated 4.9.53
  270. * @return bool
  271. * @throws InvalidArgumentException
  272. * @throws InvalidDataTypeException
  273. * @throws InvalidInterfaceException
  274. */
  275. public function isBot()
  276. {
  277. return $this->request()->isBot();
  278. }
  279. /**
  280. * @deprecated 4.9.53
  281. * @param bool $is_bot
  282. * @throws InvalidArgumentException
  283. * @throws InvalidDataTypeException
  284. * @throws InvalidInterfaceException
  285. */
  286. public function setIsBot($is_bot)
  287. {
  288. $this->request()->setIsBot($is_bot);
  289. }
  290. /**
  291. * check if a request parameter exists whose key that matches the supplied wildcard pattern
  292. * and return the value for the first match found
  293. * wildcards can be either of the following:
  294. * ? to represent a single character of any type
  295. * * to represent one or more characters of any type
  296. *
  297. * @param string $pattern
  298. * @param null|mixed $default
  299. * @return false|int
  300. * @throws InvalidArgumentException
  301. * @throws InvalidInterfaceException
  302. * @throws InvalidDataTypeException
  303. */
  304. public function getMatch($pattern, $default = null)
  305. {
  306. return $this->request()->getMatch($pattern, $default);
  307. }
  308. /**
  309. * check if a request parameter exists whose key matches the supplied wildcard pattern
  310. * wildcards can be either of the following:
  311. * ? to represent a single character of any type
  312. * * to represent one or more characters of any type
  313. * returns true if a match is found or false if not
  314. *
  315. * @param string $pattern
  316. * @return false|int
  317. * @throws InvalidArgumentException
  318. * @throws InvalidInterfaceException
  319. * @throws InvalidDataTypeException
  320. */
  321. public function matches($pattern)
  322. {
  323. return $this->request()->matches($pattern);
  324. }
  325. }
  326. // End of file EE_Request.core.php
  327. // Location: /core/request/EE_Request.core.php