-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mixin.php
executable file
·71 lines (60 loc) · 1.69 KB
/
Mixin.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
<?php
/**
* Extroller_Mixin
*
* @category Addon
* @package addon.extroller
* @author Ebine Yutaka <[email protected]>
* @copyright 2004-2008 Mori Reo <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
class Extroller_Mixin extends Sabel_Controller_Page
{
const FLASH_SESSION_KEY = "__flash_message__";
public function checkClientId($requestKey = "SBL_CLIENT_ID")
{
$clientId = $this->request->getValueWithMethod($requestKey);
return ($this->session->getClientId() === $clientId);
}
public function isAjax()
{
return ($this->request->getHttpHeader("X-Requested-With") === "XMLHttpRequest");
}
public function isPost()
{
return $this->request->isPost();
}
public function isGet()
{
return $this->request->isGet();
}
public function badRequest()
{
$this->response->getStatus()->setCode(Sabel_Response::BAD_REQUEST);
}
public function notFound()
{
$this->response->getStatus()->setCode(Sabel_Response::NOT_FOUND);
}
public function forbidden()
{
$this->response->getStatus()->setCode(Sabel_Response::FORBIDDEN);
}
public function serverError()
{
$this->response->getStatus()->setCode(Sabel_Response::INTERNAL_SERVER_ERROR);
}
public function getLogic($name)
{
$className = "Logics_" . ucfirst($name);
if (Sabel::using($className)) {
return Sabel_Container::load($className, new Logics_DI());
}
$message = __METHOD__ . "() logic class not found.";
throw new Sabel_Exception_ClassNotFound($message);
}
public function setFlash($message)
{
$this->session->write(self::FLASH_SESSION_KEY, $message, 1);
}
}