-
Notifications
You must be signed in to change notification settings - Fork 1
/
ResponseSelector.php
105 lines (94 loc) · 3.01 KB
/
ResponseSelector.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace Xmf\Xadr;
/**
* A ResponseSelector specifies which Responder object should be used for the current Action.
* The response code is used to determine the name of the responder, which by default is derived
* from the current unit and action. An different unit and action can also be specified.
*
* The response code Xadr::RESPONSE_NONE is special, as it will result in no Responder phase.
*
* @category Xmf\Xadr\ResponseSelector
* @package Xmf
* @author Richard Griffith <[email protected]>
* @copyright 2015 XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link http://xoops.org
*/
class ResponseSelector
{
/**
* @var string The response code (Responder suffix,) typically a Xadr::RESPONSE_* constant.
*/
protected $responseCode = null;
/**
* @var string Unit used to select the Responder
*/
protected $responseUnit = null;
/**
* @var string Action used to select the Responder
*/
protected $responseAction = null;
/**
* @param string $responseCode Response type code used to select Responder
* @param string|null $responseUnit Unit used to select Responder, null for default
* @param string|null $responseAction Action used to select Responder, null for default
*/
public function __construct($responseCode, $responseUnit = null, $responseAction = null)
{
$this->responseCode = $responseCode;
$this->responseUnit = $responseUnit;
$this->responseAction = $responseAction;
}
/**
* get the response code
*
* @return string
*/
public function getResponseCode()
{
return $this->responseCode;
}
/**
* get the response code
*
* @return string
*/
public function getResponseUnit()
{
return $this->responseUnit;
}
/**
* get the response code
*
* @return string
*/
public function getResponseAction()
{
return $this->responseAction;
}
/**
* Set the responseUnit and responseAction properties to supplied defaults if null.
*
* @param string $defaultUnit Unit used to select Responder
* @param string $defaultAction Action used to select Responder
*
* @return void
*/
public function setDefaultAction($defaultUnit, $defaultAction)
{
if ($this->responseUnit === null) {
$this->responseUnit = $defaultUnit;
}
if ($this->responseAction === null) {
$this->responseAction = $defaultAction;
}
}
}