1 | <?php |
||
30 | abstract class EE_Shortcodes extends EE_Base |
||
31 | { |
||
32 | |||
33 | /** |
||
34 | * holds label for library |
||
35 | * This is used for referencing the library label |
||
36 | * |
||
37 | * @access public |
||
38 | * @var string |
||
39 | */ |
||
40 | public $label; |
||
41 | |||
42 | |||
43 | /** |
||
44 | * This property is used for referencing a short description of the library |
||
45 | * |
||
46 | * @access public |
||
47 | * @var string |
||
48 | */ |
||
49 | public $description; |
||
50 | |||
51 | |||
52 | /** |
||
53 | * This will hold an array of shortcodes with the key as the shortcode ([shortcode]) and the value as a |
||
54 | * label/description for the shortcode. |
||
55 | * |
||
56 | * @access protected |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $_shortcodes; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * This will hold the incoming data item sent to the parser method |
||
64 | * |
||
65 | * @access protected |
||
66 | * @var mixed (array|object) |
||
67 | */ |
||
68 | protected $_data; |
||
69 | |||
70 | |||
71 | /** |
||
72 | * some shortcodes may require extra data to parse. This property is provided for that. |
||
73 | * |
||
74 | * @var array |
||
75 | */ |
||
76 | protected $_extra_data; |
||
77 | |||
78 | |||
79 | /** |
||
80 | * EE_messenger used to generate the template being parsed. |
||
81 | * |
||
82 | * @since 4.5.0 |
||
83 | * @var EE_messenger |
||
84 | */ |
||
85 | protected $_messenger; |
||
86 | |||
87 | |||
88 | /** |
||
89 | * message type used to generate the template being parsed. |
||
90 | * |
||
91 | * @since 4.5.0 |
||
92 | * @var EE_message_type |
||
93 | */ |
||
94 | protected $_message_type; |
||
95 | |||
96 | |||
97 | /** |
||
98 | * context used for the template being parsed |
||
99 | * |
||
100 | * @since 4.5.0 |
||
101 | * @var string |
||
102 | */ |
||
103 | protected $_context; |
||
104 | |||
105 | |||
106 | /** |
||
107 | * Specific Message Template Group ID |
||
108 | * |
||
109 | * @since 4.5.0 |
||
110 | * @var int |
||
111 | */ |
||
112 | protected $_GRP_ID; |
||
113 | |||
114 | |||
115 | /** |
||
116 | * @since 4.9.0 |
||
117 | * @type EE_Message |
||
118 | */ |
||
119 | protected $_message; |
||
120 | |||
121 | |||
122 | /** |
||
123 | * This will hold an instance of the EEH_Parse_Shortcodes helper that will be used when handling list type |
||
124 | * shortcodes |
||
125 | * |
||
126 | * @var EEH_Parse_Shortcodes |
||
127 | */ |
||
128 | protected $_shortcode_helper; |
||
129 | |||
130 | |||
131 | public function __construct() |
||
136 | |||
137 | |||
138 | /** |
||
139 | * This sets the defaults for the properties. Child classes will override these properties in their _init_props |
||
140 | * method |
||
141 | */ |
||
142 | private function _set_defaults() |
||
148 | |||
149 | |||
150 | /** |
||
151 | * loads an instance of the EE_Shortcode_Parser helper when requested |
||
152 | */ |
||
153 | protected function _set_shortcode_helper() |
||
158 | |||
159 | |||
160 | public function get_shortcode_helper() |
||
167 | |||
168 | |||
169 | /** |
||
170 | * This is the public method for kicking of the parser included with each child. It can be overridden by child |
||
171 | * classes if necessary (see EE_Questions_Answers for example) |
||
172 | * |
||
173 | * @param string $shortcode incoming shortcode to be parsed |
||
174 | * @param mixed (object|array) $data incoming data to be be used for parsing |
||
175 | * @param mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee) |
||
176 | * @return string parsed shortcode. |
||
177 | */ |
||
178 | public function parser($shortcode, $data, $extra_data = array()) |
||
202 | |||
203 | |||
204 | /** |
||
205 | * This method just returns the shortcodes in the $_shortcodes array property. |
||
206 | * |
||
207 | * @access public |
||
208 | * @return array array of shortcodes => description pairs |
||
209 | */ |
||
210 | public function get_shortcodes() |
||
219 | |||
220 | |||
221 | /** |
||
222 | * Child classes use this method to set the $name, $description, and $_shortcodes properties. |
||
223 | * |
||
224 | * @abstract |
||
225 | * @access protected |
||
226 | * @return void |
||
227 | */ |
||
228 | abstract protected function _init_props(); |
||
229 | |||
230 | |||
231 | /** |
||
232 | * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
||
233 | * will have to take care of handling. |
||
234 | * |
||
235 | * @abstract |
||
236 | * @access protected |
||
237 | * @param string $shortcode the shortcode to be parsed. |
||
238 | * @param mixed (object|array) $data incoming data for the parser. The data could be either an object or |
||
239 | * array because there are some shortcodes that might be replaced by prepared data that |
||
240 | * has multiple items in a list (i.e. list of attendees in an event and we're showing |
||
241 | * fname/lname for each attendee). In this case data will be in an array. Otherwise |
||
242 | * the data shoudl be in a properly formatted object. The |
||
243 | * EEH_Parse_Shortcodes.helper.php describes the data object we're expecting. |
||
244 | * @return string parsed shortcode |
||
245 | */ |
||
246 | abstract protected function _parser($shortcode); |
||
247 | |||
248 | |||
249 | /** |
||
250 | * This just validates incoming data for list type shortcode parsers (and they call this method) to make sure it |
||
251 | * meets their requirements |
||
252 | * |
||
253 | * @return mixed (void|exception) If validation fails we'll throw an exception. |
||
254 | */ |
||
255 | protected function _validate_list_requirements() |
||
284 | |||
285 | |||
286 | /** |
||
287 | * This returns any attributes that may be existing on an EE_Shortcode |
||
288 | * |
||
289 | * @since 4.5.0 |
||
290 | * @param string $shortcode incoming shortcode |
||
291 | * @return array An array with the attributes |
||
292 | */ |
||
293 | protected function _get_shortcode_attrs($shortcode) |
||
305 | |||
306 | |||
307 | /** |
||
308 | * This sets the properties related to the messages system |
||
309 | * |
||
310 | * @since 4.5.0 |
||
311 | * @return void |
||
312 | */ |
||
313 | protected function _set_messages_properties() |
||
324 | |||
325 | |||
326 | /** |
||
327 | * This returns whatever the set message type object is that was set on this shortcode parser. |
||
328 | * |
||
329 | * @since 4.5.0 |
||
330 | * @return EE_message_type |
||
331 | */ |
||
332 | public function get_set_message_type() |
||
336 | |||
337 | |||
338 | /** |
||
339 | * This returns whatever the set messenger object is that was set on this shortcode parser |
||
340 | * |
||
341 | * @since 4.5.0 |
||
342 | * @return EE_messenger |
||
343 | */ |
||
344 | public function get_set_messenger() |
||
348 | |||
349 | |||
350 | /** |
||
351 | * This returns whatever the set context string is on this shortcode parser. |
||
352 | * |
||
353 | * @since 4.5.0 |
||
354 | * @return string |
||
355 | */ |
||
356 | public function get_set_context() |
||
360 | |||
361 | |||
362 | /** |
||
363 | * This returns whatever the set EE_Message object is on this shortcode. |
||
364 | * |
||
365 | * @since 4.9.0 |
||
366 | * @return EE_Message |
||
367 | */ |
||
368 | public function get_set_message() |
||
372 | |||
373 | |||
374 | } //end EE_Shortcodes |
||
375 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.