|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright (c) 2011-present Mediasift Ltd |
|
5
|
|
|
* Copyright (c) 2016-present Ganbaro Digital Ltd |
|
6
|
|
|
* All rights reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* Redistribution and use in source and binary forms, with or without |
|
9
|
|
|
* modification, are permitted provided that the following conditions |
|
10
|
|
|
* are met: |
|
11
|
|
|
* |
|
12
|
|
|
* * Redistributions of source code must retain the above copyright |
|
13
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
14
|
|
|
* |
|
15
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
|
16
|
|
|
* notice, this list of conditions and the following disclaimer in |
|
17
|
|
|
* the documentation and/or other materials provided with the |
|
18
|
|
|
* distribution. |
|
19
|
|
|
* |
|
20
|
|
|
* * Neither the names of the copyright holders nor the names of his |
|
21
|
|
|
* contributors may be used to endorse or promote products derived |
|
22
|
|
|
* from this software without specific prior written permission. |
|
23
|
|
|
* |
|
24
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
25
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
26
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
27
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
28
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
29
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
30
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
31
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
32
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
33
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
34
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
35
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
|
36
|
|
|
* |
|
37
|
|
|
* @category Libraries |
|
38
|
|
|
* @package StoryplayerInternals/Framework |
|
39
|
|
|
* @author Stuart Herbert <[email protected]> |
|
40
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
|
41
|
|
|
* @copyright 2016-present Ganbaro Digital Ltd www.ganbarodigital.com |
|
42
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
43
|
|
|
* @link http://datasift.github.io/storyplayer |
|
44
|
|
|
*/ |
|
45
|
|
|
|
|
46
|
|
|
namespace StoryplayerInternals\SPv3\Framework\Actionables\BaseTemplate; |
|
47
|
|
|
|
|
48
|
|
|
use ReflectionObject; |
|
49
|
|
|
|
|
50
|
|
|
use GanbaroDigital\Actionables\Values\Actionable; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Base class for all templates |
|
54
|
|
|
* |
|
55
|
|
|
* @category Libraries |
|
56
|
|
|
* @package StoryplayerInternals/Framework |
|
57
|
|
|
* @author Stuart Herbert <[email protected]> |
|
58
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
|
59
|
|
|
* @copyright 2016-present Ganbaro Digital Ltd www.ganbarodigital.com |
|
60
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
61
|
|
|
* @link http://datasift.github.io/storyplayer |
|
62
|
|
|
*/ |
|
63
|
|
|
class BaseTemplate |
|
64
|
|
|
{ |
|
65
|
|
|
/** |
|
66
|
|
|
* I don't know what I'm doing with parameters in templates yet |
|
67
|
|
|
* @return [type] [description] |
|
|
|
|
|
|
68
|
|
|
*/ |
|
69
|
|
|
public function getParams() |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
return $this->params; |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function setParams($params = array()) |
|
75
|
|
|
{ |
|
76
|
|
|
$this->params = $params; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* does our subclass provide a method called 'perPhaseSetup'? |
|
81
|
|
|
* |
|
82
|
|
|
* @return boolean |
|
83
|
|
|
* TRUE if it does |
|
84
|
|
|
* FALSE otherwise |
|
85
|
|
|
*/ |
|
86
|
|
|
public function hasPerPhaseSetup() |
|
87
|
|
|
{ |
|
88
|
|
|
return method_exists($this, 'perPhaseSetup'); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* does our subclass provide a method called 'perPhaseTeardown'? |
|
93
|
|
|
* |
|
94
|
|
|
* @return boolean |
|
95
|
|
|
* TRUE if it does |
|
96
|
|
|
* FALSE otherwise |
|
97
|
|
|
*/ |
|
98
|
|
|
public function hasPerPhaseTeardown() |
|
99
|
|
|
{ |
|
100
|
|
|
return method_exists($this, 'perPhaseTeardown'); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* does our subclass provide a method called 'deviceSetup'? |
|
105
|
|
|
* |
|
106
|
|
|
* @return boolean |
|
107
|
|
|
* TRUE if it does |
|
108
|
|
|
* FALSE otherwise |
|
109
|
|
|
*/ |
|
110
|
|
|
public function hasDeviceSetup() |
|
111
|
|
|
{ |
|
112
|
|
|
return method_exists($this, 'deviceSetup'); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* does our subclass provide a method called 'deviceTeardown'? |
|
117
|
|
|
* |
|
118
|
|
|
* @return boolean |
|
119
|
|
|
* TRUE if it does |
|
120
|
|
|
* FALSE otherwise |
|
121
|
|
|
*/ |
|
122
|
|
|
public function hasDeviceTeardown() |
|
123
|
|
|
{ |
|
124
|
|
|
return method_exists($this, 'deviceTeardown'); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* return our 'perPhaseSetup' method as a callable |
|
129
|
|
|
* |
|
130
|
|
|
* @return callable |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getPerPhaseSetup() |
|
133
|
|
|
{ |
|
134
|
|
|
return new Actionable( |
|
135
|
|
|
[$this, 'perPhaseSetup'], |
|
136
|
|
|
$this->getSourceFilename(), |
|
137
|
|
|
[ 'perPhaseSetup' ] |
|
138
|
|
|
); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* return our 'perPhaseTeardown' method as a callable |
|
143
|
|
|
* |
|
144
|
|
|
* @return callable |
|
145
|
|
|
*/ |
|
146
|
|
|
public function getPerPhaseTeardown() |
|
147
|
|
|
{ |
|
148
|
|
|
return new Actionable( |
|
149
|
|
|
[$this, 'perPhaseTeardown'], |
|
150
|
|
|
$this->getSourceFilename(), |
|
151
|
|
|
[ 'perPhaseTeardown' ] |
|
152
|
|
|
); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* return our 'deviceSetup' method as a callable |
|
157
|
|
|
* |
|
158
|
|
|
* @return callable |
|
159
|
|
|
*/ |
|
160
|
|
|
public function getDeviceSetup() |
|
161
|
|
|
{ |
|
162
|
|
|
return new Actionable( |
|
163
|
|
|
[$this, 'deviceSetup'], |
|
164
|
|
|
$this->getSourceFilename(), |
|
165
|
|
|
[ 'deviceSetup' ] |
|
166
|
|
|
); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* return our 'deviceTeardown' method as a callable |
|
171
|
|
|
* |
|
172
|
|
|
* @return callable |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getDeviceTeardown() |
|
175
|
|
|
{ |
|
176
|
|
|
return new Actionable( |
|
177
|
|
|
[$this, 'deviceTeardown'], |
|
178
|
|
|
$this->getSourceFilename(), |
|
179
|
|
|
[ 'deviceTeardown' ] |
|
180
|
|
|
); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* which file is this template defined in? |
|
185
|
|
|
* |
|
186
|
|
|
* @return string |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getSourceFilename() |
|
189
|
|
|
{ |
|
190
|
|
|
$refObj = new ReflectionObject($this); |
|
191
|
|
|
return $refObj->getFileName(); |
|
192
|
|
|
} |
|
193
|
|
|
} |
|
194
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.