forked from Enrise/Glitch_Lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Request.php
83 lines (78 loc) · 1.98 KB
/
Request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Glitch
*
* This source file is proprietary and protected by international
* copyright and trade secret laws. No part of this source file may
* be reproduced, copied, adapted, modified, distributed, transferred,
* translated, disclosed, displayed or otherwise used by anyone in any
* form or by any means without the express written authorization of
* 4worx software innovators BV (www.4worx.com)
*
* @category Glitch
* @package Glitch
* @author 4worx <info@4worx.com>
* @copyright 2010, 4worx
* @version $Id$
*/
/**
* Convenience class for easy-accessing the request object
*
* @category Glitch
* @package Glitch
*/
class Glitch_Request
{
/**
* Request object
*
* @staticvar Zend_Controller_Request_Abstract
*/
protected static $_request = null;
/**
* Gets the request object
*
* @return Zend_Controller_Request_Abstract
*/
public static function getRequest()
{
// If no request object was set, use fallback
if (null === self::$_request)
{
self::setRequest(Zend_Controller_Front::getInstance()->getRequest());
}
return self::$_request;
}
/**
* Sets the request object
*
* Method primarily exists for a clean interface, as the complement of getRequest().
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public static function setRequest(Zend_Controller_Request_Abstract $request)
{
self::$_request = $request;
}
/**
* Checks whether the current request is a POST method
*
* @return boolean
*/
public static function isPost()
{
return self::getRequest()->isPost();
}
/**
* Gets an action parameter
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function getParam($key, $default = null)
{
return self::getRequest()->getParam($key, $default);
}
}