1 | <?php |
||
7 | class Base implements ContextInterface |
||
8 | { |
||
9 | /** |
||
10 | * Meaninful information about the context |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $info = []; |
||
15 | |||
16 | /** |
||
17 | * Context name |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $name; |
||
22 | |||
23 | /** |
||
24 | * Hash to identify an operation using this context |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $hash; |
||
29 | |||
30 | /** |
||
31 | * DataWrapper |
||
32 | * |
||
33 | * @var DataWrapper\DataWrapperInterface |
||
34 | */ |
||
35 | protected $dataWrapper; |
||
36 | |||
37 | /** |
||
38 | * @param DataWrapper\DataWrapperInterface $dataWrapper |
||
39 | */ |
||
40 | 12 | public function __construct(DataWrapper\DataWrapperInterface $dataWrapper) |
|
44 | |||
45 | /** |
||
46 | * Magic method to add additional meaninful information about the context |
||
47 | * |
||
48 | * @param string $method |
||
49 | * @param array $arguments |
||
50 | * @return mixed |
||
51 | */ |
||
52 | 3 | public function __call($method, array $arguments) |
|
76 | |||
77 | /** |
||
78 | * Returns all the info values |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | 1 | public function getFullInfo() |
|
83 | { |
||
84 | 1 | return $this->info; |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * Set the info property |
||
89 | * |
||
90 | * @param array $fullInfo |
||
91 | * @return Base |
||
92 | */ |
||
93 | 1 | public function setFullInfo(array $fullInfo) |
|
94 | { |
||
95 | 1 | $this->info = $fullInfo; |
|
96 | 1 | return $this; |
|
97 | } |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | 3 | public function getDataWrapper() |
|
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | 12 | public function setDataWrapper(DataWrapper\DataWrapperInterface $dataWrapper) |
|
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | 3 | public function getHash() |
|
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | 1 | public function setHash($hash) |
|
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | 5 | public function getName() |
|
150 | |||
151 | /** |
||
152 | * @param string $name |
||
153 | * @return Base |
||
154 | */ |
||
155 | 3 | public function setName($name) |
|
160 | |||
161 | /** |
||
162 | * Generate a unique hash |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | 2 | protected function generateHash() |
|
170 | |||
171 | /** |
||
172 | * Export context data |
||
173 | * |
||
174 | * @return void |
||
175 | * {@inheritdoc} |
||
176 | */ |
||
177 | 1 | public function exportContextData() |
|
181 | |||
182 | /** |
||
183 | * Prepare the info to be exported |
||
184 | * |
||
185 | * @param array |
||
186 | * @return array |
||
187 | */ |
||
188 | 1 | protected function prepareExport($data) |
|
198 | } |
||
199 |