Some updates:
[core.git] / inc / main / classes / resolver / class_
diff --git a/inc/main/classes/resolver/class_ b/inc/main/classes/resolver/class_
new file mode 100644 (file)
index 0000000..0813fe5
--- /dev/null
@@ -0,0 +1,577 @@
+<?php
+/**
+ * A ??? resolver
+ * @TODO Clean up this template
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Resolver extends BaseResolver implements Resolver {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to '???'
+               $this->setClassPrefix('???');
+       }
+
+       /**
+        * Creates an instance of a Html action resolver with a given default action
+        *
+        * @param       $!!!Name                                The default action we shall execute
+        * @param       $appInstance                    An instance of a manageable application helper class
+        * @return      $resolverInstance               The prepared action resolver instance
+        * @throws      EmptyVariableException  Thrown if default action is not set
+        * @throws      Invalid|||Exception     Thrown if default action is invalid
+        */
+       public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new ???Resolver();
+
+               // Is the variable $!!!Name set and the action is valid?
+               if (empty($!!!Name)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
+                       // Invalid action found
+                       throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an action instance for a given request class or null if
+        * it was not found
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $!!!Instance    An instance of the resolved action
+        * @throws      Invalid|||Exception                             Thrown if $!!!Name is
+        *                                                                                              invalid
+        * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
+        *                                                                                              is an invalid instance
+        */
+       public function resolve|||ByRequest (Requestable $requestInstance) {
+               // Init variables
+               $!!!Name = '';
+               $!!!Instance = null;
+
+               // This goes fine so let's resolve the action
+               $!!!Name = $requestInstance->getRequestElement('action');
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // And validate it
+               if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
+                       // This action has an invalid instance!
+                       throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Set last action
+               $this->setResolvedInstance($!!!Instance);
+
+               // Return the resolved action instance
+               return $!!!Instance;
+       }
+
+       /**
+        * Resolves the action by its direct name and returns an instance of its class
+        *
+        * @return      $!!!Instance            An instance of the action class
+        * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
+        */
+       public function resolve||| () {
+               // Initiate the instance variable
+               $!!!Instance = null;
+
+               // Get action name
+               $!!!Name = $this->get|||Name();
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) {
+                       $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+               } // END - if
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // Return the instance
+               return $!!!Instance;
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * A ??? resolver
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Resolver extends BaseResolver implements Resolver {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to '???'
+               $this->setClassPrefix('???');
+       }
+
+       /**
+        * Creates an instance of a Html action resolver with a given default action
+        *
+        * @param       $!!!Name                                The default action we shall execute
+        * @param       $appInstance                    An instance of a manageable application helper class
+        * @return      $resolverInstance               The prepared action resolver instance
+        * @throws      EmptyVariableException  Thrown if default action is not set
+        * @throws      Invalid|||Exception     Thrown if default action is invalid
+        */
+       public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new ???Resolver();
+
+               // Is the variable $!!!Name set and the action is valid?
+               if (empty($!!!Name)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
+                       // Invalid action found
+                       throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an action instance for a given request class or null if
+        * it was not found
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $!!!Instance    An instance of the resolved action
+        * @throws      Invalid|||Exception                             Thrown if $!!!Name is
+        *                                                                                              invalid
+        * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
+        *                                                                                              is an invalid instance
+        */
+       public function resolve|||ByRequest (Requestable $requestInstance) {
+               // Init variables
+               $!!!Name = '';
+               $!!!Instance = null;
+
+               // This goes fine so let's resolve the action
+               $!!!Name = $requestInstance->getRequestElement('action');
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // And validate it
+               if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
+                       // This action has an invalid instance!
+                       throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Set last action
+               $this->setResolvedInstance($!!!Instance);
+
+               // Return the resolved action instance
+               return $!!!Instance;
+       }
+
+       /**
+        * Resolves the action by its direct name and returns an instance of its class
+        *
+        * @return      $!!!Instance            An instance of the action class
+        * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
+        */
+       public function resolve||| () {
+               // Initiate the instance variable
+               $!!!Instance = null;
+
+               // Get action name
+               $!!!Name = $this->get|||Name();
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) {
+                       $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+               } // END - if
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // Return the instance
+               return $!!!Instance;
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * A ??? resolver
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Resolver extends BaseResolver implements Resolver {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to '???'
+               $this->setClassPrefix('???');
+       }
+
+       /**
+        * Creates an instance of a Html action resolver with a given default action
+        *
+        * @param       $!!!Name                                The default action we shall execute
+        * @param       $appInstance                    An instance of a manageable application helper class
+        * @return      $resolverInstance               The prepared action resolver instance
+        * @throws      EmptyVariableException  Thrown if default action is not set
+        * @throws      Invalid|||Exception     Thrown if default action is invalid
+        */
+       public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new ???Resolver();
+
+               // Is the variable $!!!Name set and the action is valid?
+               if (empty($!!!Name)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
+                       // Invalid action found
+                       throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an action instance for a given request class or null if
+        * it was not found
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $!!!Instance    An instance of the resolved action
+        * @throws      Invalid|||Exception                             Thrown if $!!!Name is
+        *                                                                                              invalid
+        * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
+        *                                                                                              is an invalid instance
+        */
+       public function resolve|||ByRequest (Requestable $requestInstance) {
+               // Init variables
+               $!!!Name = '';
+               $!!!Instance = null;
+
+               // This goes fine so let's resolve the action
+               $!!!Name = $requestInstance->getRequestElement('action');
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // And validate it
+               if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
+                       // This action has an invalid instance!
+                       throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Set last action
+               $this->setResolvedInstance($!!!Instance);
+
+               // Return the resolved action instance
+               return $!!!Instance;
+       }
+
+       /**
+        * Resolves the action by its direct name and returns an instance of its class
+        *
+        * @return      $!!!Instance            An instance of the action class
+        * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
+        */
+       public function resolve||| () {
+               // Initiate the instance variable
+               $!!!Instance = null;
+
+               // Get action name
+               $!!!Name = $this->get|||Name();
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) {
+                       $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+               } // END - if
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // Return the instance
+               return $!!!Instance;
+       }
+}
+
+// [EOF]
+?>
+<?php
+/**
+ * A ??? resolver
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Resolver extends BaseResolver implements Resolver {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set prefix to '???'
+               $this->setClassPrefix('???');
+       }
+
+       /**
+        * Creates an instance of a ??? resolver with a given default action
+        *
+        * @param       $!!!Name                                The default action we shall execute
+        * @param       $appInstance                    An instance of a manageable application helper class
+        * @return      $resolverInstance               The prepared action resolver instance
+        * @throws      EmptyVariableException  Thrown if default action is not set
+        * @throws      Invalid|||Exception     Thrown if default action is invalid
+        */
+       public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
+               // Create the new instance
+               $resolverInstance = new ???Resolver();
+
+               // Is the variable $!!!Name set and the action is valid?
+               if (empty($!!!Name)) {
+                       // Then thrown an exception here
+                       throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) {
+                       // Invalid action found
+                       throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               }
+
+               // Set the application instance
+               $resolverInstance->setApplicationInstance($appInstance);
+
+               // Return the prepared instance
+               return $resolverInstance;
+       }
+
+       /**
+        * Returns an action instance for a given request class or null if
+        * it was not found
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $!!!Instance    An instance of the resolved action
+        * @throws      Invalid|||Exception                             Thrown if $!!!Name is
+        *                                                                                              invalid
+        * @throws      Invalid|||InstanceException             Thrown if $!!!Instance
+        *                                                                                              is an invalid instance
+        */
+       public function resolve|||ByRequest (Requestable $requestInstance) {
+               // Init variables
+               $!!!Name = '';
+               $!!!Instance = null;
+
+               // This goes fine so let's resolve the action
+               $!!!Name = $requestInstance->getRequestElement('action');
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // And validate it
+               if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
+                       // This action has an invalid instance!
+                       throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Set last action
+               $this->setResolvedInstance($!!!Instance);
+
+               // Return the resolved action instance
+               return $!!!Instance;
+       }
+
+       /**
+        * Resolves the action by its direct name and returns an instance of its class
+        *
+        * @return      $!!!Instance            An instance of the action class
+        * @throws      Invalid|||Exception     Thrown if $!!!Name is invalid
+        */
+       public function resolve||| () {
+               // Initiate the instance variable
+               $!!!Instance = null;
+
+               // Get action name
+               $!!!Name = $this->get|||Name();
+
+               // Is the action empty? Then fall back to default action
+               if (empty($!!!Name)) {
+                       $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action');
+               } // END - if
+
+               // Check if action is valid
+               if ($this->is|||Valid($!!!Name) === FALSE) {
+                       // This action is invalid!
+                       throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
+               } // END - if
+
+               // Get the action
+               $!!!Instance = $this->load|||();
+
+               // Return the instance
+               return $!!!Instance;
+       }
+}
+
+// [EOF]
+?>