update copyright as changes will happen this year
[core.git] / inc / main / classes / resolver / class_
1 <?php
2 /**
3  * A ??? resolver
4  * @TODO Clean up this template
5  *
6  * @author              Roland Haeder <webmaster@ship-simu.org>
7  * @version             0.0.0
8  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
9  * @license             GNU GPL 3.0 or any newer version
10  * @link                http://www.ship-simu.org
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 class ???Resolver extends BaseResolver implements Resolver {
26         /**
27          * Protected constructor
28          *
29          * @return      void
30          */
31         protected function __construct () {
32                 // Call parent constructor
33                 parent::__construct(__CLASS__);
34
35                 // Set prefix to '???'
36                 $this->setClassPrefix('???');
37         }
38
39         /**
40          * Creates an instance of a Html action resolver with a given default action
41          *
42          * @param       $!!!Name                                The default action we shall execute
43          * @param       $appInstance                    An instance of a manageable application helper class
44          * @return      $resolverInstance               The prepared action resolver instance
45          * @throws      EmptyVariableException  Thrown if default action is not set
46          * @throws      Invalid|||Exception     Thrown if default action is invalid
47          */
48         public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
49                 // Create the new instance
50                 $resolverInstance = new ???Resolver();
51
52                 // Is the variable $!!!Name set and the action is valid?
53                 if (empty($!!!Name)) {
54                         // Then thrown an exception here
55                         throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
56                 } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
57                         // Invalid action found
58                         throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
59                 }
60
61                 // Set the application instance
62                 $resolverInstance->setApplicationInstance($appInstance);
63
64                 // Return the prepared instance
65                 return $resolverInstance;
66         }
67
68         /**
69          * Returns an action instance for a given request class or null if
70          * it was not found
71          *
72          * @param       $requestInstance        An instance of a request class
73          * @return      $!!!Instance    An instance of the resolved action
74          * @throws      Invalid|||Exception                             Thrown if $!!!Name is
75          *                                                                                              invalid
76          * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
77          *                                                                                              is an invalid instance
78          */
79         public function resolve|||ByRequest (Requestable $requestInstance) {
80                 // Init variables
81                 $!!!Name = '';
82                 $!!!Instance = null;
83
84                 // This goes fine so let's resolve the action
85                 $!!!Name = $requestInstance->getRequestElement('action');
86
87                 // Is the action empty? Then fall back to default action
88                 if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
89
90                 // Check if action is valid
91                 if ($this->is|||Valid($!!!Name) === FALSE) {
92                         // This action is invalid!
93                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
94                 } // END - if
95
96                 // Get the action
97                 $!!!Instance = $this->load|||();
98
99                 // And validate it
100                 if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
101                         // This action has an invalid instance!
102                         throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
103                 } // END - if
104
105                 // Set last action
106                 $this->setResolvedInstance($!!!Instance);
107
108                 // Return the resolved action instance
109                 return $!!!Instance;
110         }
111
112         /**
113          * Resolves the action by its direct name and returns an instance of its class
114          *
115          * @return      $!!!Instance            An instance of the action class
116          * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
117          */
118         public function resolve||| () {
119                 // Initiate the instance variable
120                 $!!!Instance = null;
121
122                 // Get action name
123                 $!!!Name = $this->get|||Name();
124
125                 // Is the action empty? Then fall back to default action
126                 if (empty($!!!Name)) {
127                         $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
128                 } // END - if
129
130                 // Check if action is valid
131                 if ($this->is|||Valid($!!!Name) === FALSE) {
132                         // This action is invalid!
133                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
134                 } // END - if
135
136                 // Get the action
137                 $!!!Instance = $this->load|||();
138
139                 // Return the instance
140                 return $!!!Instance;
141         }
142 }
143
144 // [EOF]
145 ?>
146 <?php
147 /**
148  * A ??? resolver
149  *
150  * @author              Roland Haeder <webmaster@ship-simu.org>
151  * @version             0.0.0
152  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
153  * @license             GNU GPL 3.0 or any newer version
154  * @link                http://www.ship-simu.org
155  *
156  * This program is free software: you can redistribute it and/or modify
157  * it under the terms of the GNU General Public License as published by
158  * the Free Software Foundation, either version 3 of the License, or
159  * (at your option) any later version.
160  *
161  * This program is distributed in the hope that it will be useful,
162  * but WITHOUT ANY WARRANTY; without even the implied warranty of
163  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
164  * GNU General Public License for more details.
165  *
166  * You should have received a copy of the GNU General Public License
167  * along with this program. If not, see <http://www.gnu.org/licenses/>.
168  */
169 class ???Resolver extends BaseResolver implements Resolver {
170         /**
171          * Protected constructor
172          *
173          * @return      void
174          */
175         protected function __construct () {
176                 // Call parent constructor
177                 parent::__construct(__CLASS__);
178
179                 // Set prefix to '???'
180                 $this->setClassPrefix('???');
181         }
182
183         /**
184          * Creates an instance of a Html action resolver with a given default action
185          *
186          * @param       $!!!Name                                The default action we shall execute
187          * @param       $appInstance                    An instance of a manageable application helper class
188          * @return      $resolverInstance               The prepared action resolver instance
189          * @throws      EmptyVariableException  Thrown if default action is not set
190          * @throws      Invalid|||Exception     Thrown if default action is invalid
191          */
192         public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
193                 // Create the new instance
194                 $resolverInstance = new ???Resolver();
195
196                 // Is the variable $!!!Name set and the action is valid?
197                 if (empty($!!!Name)) {
198                         // Then thrown an exception here
199                         throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
200                 } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
201                         // Invalid action found
202                         throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
203                 }
204
205                 // Set the application instance
206                 $resolverInstance->setApplicationInstance($appInstance);
207
208                 // Return the prepared instance
209                 return $resolverInstance;
210         }
211
212         /**
213          * Returns an action instance for a given request class or null if
214          * it was not found
215          *
216          * @param       $requestInstance        An instance of a request class
217          * @return      $!!!Instance    An instance of the resolved action
218          * @throws      Invalid|||Exception                             Thrown if $!!!Name is
219          *                                                                                              invalid
220          * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
221          *                                                                                              is an invalid instance
222          */
223         public function resolve|||ByRequest (Requestable $requestInstance) {
224                 // Init variables
225                 $!!!Name = '';
226                 $!!!Instance = null;
227
228                 // This goes fine so let's resolve the action
229                 $!!!Name = $requestInstance->getRequestElement('action');
230
231                 // Is the action empty? Then fall back to default action
232                 if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
233
234                 // Check if action is valid
235                 if ($this->is|||Valid($!!!Name) === FALSE) {
236                         // This action is invalid!
237                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
238                 } // END - if
239
240                 // Get the action
241                 $!!!Instance = $this->load|||();
242
243                 // And validate it
244                 if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
245                         // This action has an invalid instance!
246                         throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
247                 } // END - if
248
249                 // Set last action
250                 $this->setResolvedInstance($!!!Instance);
251
252                 // Return the resolved action instance
253                 return $!!!Instance;
254         }
255
256         /**
257          * Resolves the action by its direct name and returns an instance of its class
258          *
259          * @return      $!!!Instance            An instance of the action class
260          * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
261          */
262         public function resolve||| () {
263                 // Initiate the instance variable
264                 $!!!Instance = null;
265
266                 // Get action name
267                 $!!!Name = $this->get|||Name();
268
269                 // Is the action empty? Then fall back to default action
270                 if (empty($!!!Name)) {
271                         $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
272                 } // END - if
273
274                 // Check if action is valid
275                 if ($this->is|||Valid($!!!Name) === FALSE) {
276                         // This action is invalid!
277                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
278                 } // END - if
279
280                 // Get the action
281                 $!!!Instance = $this->load|||();
282
283                 // Return the instance
284                 return $!!!Instance;
285         }
286 }
287
288 // [EOF]
289 ?>
290 <?php
291 /**
292  * A ??? resolver
293  *
294  * @author              Roland Haeder <webmaster@ship-simu.org>
295  * @version             0.0.0
296  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
297  * @license             GNU GPL 3.0 or any newer version
298  * @link                http://www.ship-simu.org
299  *
300  * This program is free software: you can redistribute it and/or modify
301  * it under the terms of the GNU General Public License as published by
302  * the Free Software Foundation, either version 3 of the License, or
303  * (at your option) any later version.
304  *
305  * This program is distributed in the hope that it will be useful,
306  * but WITHOUT ANY WARRANTY; without even the implied warranty of
307  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
308  * GNU General Public License for more details.
309  *
310  * You should have received a copy of the GNU General Public License
311  * along with this program. If not, see <http://www.gnu.org/licenses/>.
312  */
313 class ???Resolver extends BaseResolver implements Resolver {
314         /**
315          * Protected constructor
316          *
317          * @return      void
318          */
319         protected function __construct () {
320                 // Call parent constructor
321                 parent::__construct(__CLASS__);
322
323                 // Set prefix to '???'
324                 $this->setClassPrefix('???');
325         }
326
327         /**
328          * Creates an instance of a Html action resolver with a given default action
329          *
330          * @param       $!!!Name                                The default action we shall execute
331          * @param       $appInstance                    An instance of a manageable application helper class
332          * @return      $resolverInstance               The prepared action resolver instance
333          * @throws      EmptyVariableException  Thrown if default action is not set
334          * @throws      Invalid|||Exception     Thrown if default action is invalid
335          */
336         public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
337                 // Create the new instance
338                 $resolverInstance = new ???Resolver();
339
340                 // Is the variable $!!!Name set and the action is valid?
341                 if (empty($!!!Name)) {
342                         // Then thrown an exception here
343                         throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
344                 } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
345                         // Invalid action found
346                         throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
347                 }
348
349                 // Set the application instance
350                 $resolverInstance->setApplicationInstance($appInstance);
351
352                 // Return the prepared instance
353                 return $resolverInstance;
354         }
355
356         /**
357          * Returns an action instance for a given request class or null if
358          * it was not found
359          *
360          * @param       $requestInstance        An instance of a request class
361          * @return      $!!!Instance    An instance of the resolved action
362          * @throws      Invalid|||Exception                             Thrown if $!!!Name is
363          *                                                                                              invalid
364          * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
365          *                                                                                              is an invalid instance
366          */
367         public function resolve|||ByRequest (Requestable $requestInstance) {
368                 // Init variables
369                 $!!!Name = '';
370                 $!!!Instance = null;
371
372                 // This goes fine so let's resolve the action
373                 $!!!Name = $requestInstance->getRequestElement('action');
374
375                 // Is the action empty? Then fall back to default action
376                 if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
377
378                 // Check if action is valid
379                 if ($this->is|||Valid($!!!Name) === FALSE) {
380                         // This action is invalid!
381                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
382                 } // END - if
383
384                 // Get the action
385                 $!!!Instance = $this->load|||();
386
387                 // And validate it
388                 if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
389                         // This action has an invalid instance!
390                         throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
391                 } // END - if
392
393                 // Set last action
394                 $this->setResolvedInstance($!!!Instance);
395
396                 // Return the resolved action instance
397                 return $!!!Instance;
398         }
399
400         /**
401          * Resolves the action by its direct name and returns an instance of its class
402          *
403          * @return      $!!!Instance            An instance of the action class
404          * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
405          */
406         public function resolve||| () {
407                 // Initiate the instance variable
408                 $!!!Instance = null;
409
410                 // Get action name
411                 $!!!Name = $this->get|||Name();
412
413                 // Is the action empty? Then fall back to default action
414                 if (empty($!!!Name)) {
415                         $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
416                 } // END - if
417
418                 // Check if action is valid
419                 if ($this->is|||Valid($!!!Name) === FALSE) {
420                         // This action is invalid!
421                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
422                 } // END - if
423
424                 // Get the action
425                 $!!!Instance = $this->load|||();
426
427                 // Return the instance
428                 return $!!!Instance;
429         }
430 }
431
432 // [EOF]
433 ?>
434 <?php
435 /**
436  * A ??? resolver
437  *
438  * @author              Roland Haeder <webmaster@ship-simu.org>
439  * @version             0.0.0
440  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
441  * @license             GNU GPL 3.0 or any newer version
442  * @link                http://www.ship-simu.org
443  *
444  * This program is free software: you can redistribute it and/or modify
445  * it under the terms of the GNU General Public License as published by
446  * the Free Software Foundation, either version 3 of the License, or
447  * (at your option) any later version.
448  *
449  * This program is distributed in the hope that it will be useful,
450  * but WITHOUT ANY WARRANTY; without even the implied warranty of
451  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
452  * GNU General Public License for more details.
453  *
454  * You should have received a copy of the GNU General Public License
455  * along with this program. If not, see <http://www.gnu.org/licenses/>.
456  */
457 class ???Resolver extends BaseResolver implements Resolver {
458         /**
459          * Protected constructor
460          *
461          * @return      void
462          */
463         protected function __construct () {
464                 // Call parent constructor
465                 parent::__construct(__CLASS__);
466
467                 // Set prefix to '???'
468                 $this->setClassPrefix('???');
469         }
470
471         /**
472          * Creates an instance of a ??? resolver with a given default action
473          *
474          * @param       $!!!Name                                The default action we shall execute
475          * @param       $appInstance                    An instance of a manageable application helper class
476          * @return      $resolverInstance               The prepared action resolver instance
477          * @throws      EmptyVariableException  Thrown if default action is not set
478          * @throws      Invalid|||Exception     Thrown if default action is invalid
479          */
480         public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
481                 // Create the new instance
482                 $resolverInstance = new ???Resolver();
483
484                 // Is the variable $!!!Name set and the action is valid?
485                 if (empty($!!!Name)) {
486                         // Then thrown an exception here
487                         throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
488                 } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
489                         // Invalid action found
490                         throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
491                 }
492
493                 // Set the application instance
494                 $resolverInstance->setApplicationInstance($appInstance);
495
496                 // Return the prepared instance
497                 return $resolverInstance;
498         }
499
500         /**
501          * Returns an action instance for a given request class or null if
502          * it was not found
503          *
504          * @param       $requestInstance        An instance of a request class
505          * @return      $!!!Instance    An instance of the resolved action
506          * @throws      Invalid|||Exception                             Thrown if $!!!Name is
507          *                                                                                              invalid
508          * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
509          *                                                                                              is an invalid instance
510          */
511         public function resolve|||ByRequest (Requestable $requestInstance) {
512                 // Init variables
513                 $!!!Name = '';
514                 $!!!Instance = null;
515
516                 // This goes fine so let's resolve the action
517                 $!!!Name = $requestInstance->getRequestElement('action');
518
519                 // Is the action empty? Then fall back to default action
520                 if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
521
522                 // Check if action is valid
523                 if ($this->is|||Valid($!!!Name) === FALSE) {
524                         // This action is invalid!
525                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
526                 } // END - if
527
528                 // Get the action
529                 $!!!Instance = $this->load|||();
530
531                 // And validate it
532                 if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
533                         // This action has an invalid instance!
534                         throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
535                 } // END - if
536
537                 // Set last action
538                 $this->setResolvedInstance($!!!Instance);
539
540                 // Return the resolved action instance
541                 return $!!!Instance;
542         }
543
544         /**
545          * Resolves the action by its direct name and returns an instance of its class
546          *
547          * @return      $!!!Instance            An instance of the action class
548          * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
549          */
550         public function resolve||| () {
551                 // Initiate the instance variable
552                 $!!!Instance = null;
553
554                 // Get action name
555                 $!!!Name = $this->get|||Name();
556
557                 // Is the action empty? Then fall back to default action
558                 if (empty($!!!Name)) {
559                         $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
560                 } // END - if
561
562                 // Check if action is valid
563                 if ($this->is|||Valid($!!!Name) === FALSE) {
564                         // This action is invalid!
565                         throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
566                 } // END - if
567
568                 // Get the action
569                 $!!!Instance = $this->load|||();
570
571                 // Return the instance
572                 return $!!!Instance;
573         }
574 }
575
576 // [EOF]
577 ?>