-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDomainState.php
137 lines (124 loc) · 3.99 KB
/
DomainState.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?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;
/**
* The DomainState object provides a transient storage mechanism for Domain related
* current state data, such as result sets.
*
* Some DomainState implementations may optinally provide persistence features as well.
*
* No persitence mechanism is provided, as it will vary by Domain. For most, it is not
* required, or simple, such as storing in a session variable. More complex situations,
* such as the state of a Workflow case that needs to remain active for an indefinite
* period or be passed between multiple actors, may require database backing. All such
* details are left to the implementations of Domain and save(), fetch() and expire().
*
* @category Xmf\Xadr\DomainState
* @package Xmf
* @author Richard Griffith <[email protected]>
* @copyright 2013-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
*/
abstract class DomainState extends ContextAware
{
/**
* @var \ArrayObject|null $state domain state attribute store
*/
protected $state = null;
/**
* initContextAware - called by ContextAware::__construct
*
* @return void
*/
protected function initContextAware()
{
$this->state = new \ArrayObject;
}
/**
* Retrieve a named state attribute
*
* @param string $name name of a state attribute
* @param mixed $default default value returned if the requested state attribute is not set
*
* @return mixed current value of the named state attribute, or $default if not set
*/
public function get($name, $default = null)
{
if ($this->state->offsetExists($name)) {
return $this->state->offsetGet($name);
}
return $default;
}
/**
* Set a named state attribute
*
* @param string $name name of a state attribute
* @param mixed $value value to be set for the state
*
* @return void
*/
public function set($name, $value)
{
$this->state->offsetSet($name, $value);
}
/**
* Delete a named state attribute
*
* @param string $name name of a state attribute
*
* @return mixed value of the now deleted state attribute, or null if there was no prior value
*/
public function remove($name)
{
$value = null;
if ($this->state->offsetExists($name)) {
$value = $this->state->offsetGet($name);
$this->state->offsetUnset($name);
}
return $value;
}
/**
* Save a named state attribute to a persistent store. This method does not
* set the current state value, it only saves the value that is already set.
*
* @param string $name name of a state attribute
*
* @return void
*/
public function save($name)
{
return;
}
/**
* Fetch a named state attribute from the persistent store, and set as current
* state value for the named attribute. This method does not return the value,
* only the status of the fetch.
*
* @param string $name name of a state attribute
*
* @return boolean true if state attribute was restored, otherwise false
*/
public function fetch($name)
{
return false;
}
/**
* Delete a named state attribute from the persistent store.
*
* @param string $name name of a state attribute
*
* @return boolean true if state attribute was deleted, otherwise false
*/
public function expire($name)
{
return false;
}
}