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