]> git.mxchange.org Git - shipsimu.git/commitdiff
Moved more methods to 'core' as they are now more generalized.
authorRoland Haeder <roland@mxchange.org>
Tue, 24 Mar 2015 19:56:53 +0000 (20:56 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 24 Mar 2015 19:56:53 +0000 (20:56 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/shipsimu/main/resolver/command/html/class_HtmlCompanyCommandResolver.php
application/shipsimu/main/resolver/command/html/class_HtmlGovernmentFailedCommandResolver.php
core

index e04768c943f6f56eb64c9891530510f6acd1f702..5b5fd9c9f86ce889b698cab2db193fa793c88c07 100644 (file)
@@ -37,7 +37,7 @@ class HtmlCompanyCommandResolver extends BaseCommandResolver implements CommandR
                parent::__construct(__CLASS__);
 
                // Set prefix to "Html"
-               $this->setCommandPrefix('Html');
+               $this->setCommandPrefix('html');
        }
 
        /**
@@ -71,119 +71,6 @@ class HtmlCompanyCommandResolver extends BaseCommandResolver implements CommandR
                // Return the prepared instance
                return $resolverInstance;
        }
-
-       /**
-        * Returns an command instance for a given request class or null if
-        * it was not found
-        *
-        * @param       $requestInstance        An instance of a request class
-        * @return      $commandInstance        An instance of the resolved command
-        * @throws      InvalidCommandException                         Thrown if $commandName is
-        *                                                                                              invalid
-        * @throws      InvalidCommandInstanceException         Thrown if $commandInstance
-        *                                                                                              is an invalid instance
-        */
-       public function resolveCommandByRequest (Requestable $requestInstance) {
-               // Init instance
-               $commandInstance = null;
-
-               // This goes fine so let's resolv the command
-               $commandName = str_replace('-', '_', $requestInstance->getRequestElement('app')) . '_' . $requestInstance->getRequestElement('page');
-
-               // Is there a "failed" request?
-               if ($requestInstance->isRequestElementSet('failed')) {
-                       // Then include with within the command name
-                       $commandName = $commandName . '_' . $requestInstance->getRequestElement('failed');
-               } // END - if
-
-               // Is the command empty? Then fall back to default command
-               if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_web_command');
-
-               // Check if command is valid
-               if ($this->isCommandValid($commandName) === false) {
-                       // This command is invalid!
-                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-               } // END - if
-
-               // Get the command
-               $commandInstance = $this->loadCommand($commandName);
-
-               // And validate it
-               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
-                       // This command has an invalid instance!
-                       throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-               } // END - if
-
-               // Set last command
-               $this->lastCommandInstance = $commandInstance;
-
-               // Return the resolved command instance
-               return $commandInstance;
-       }
-
-       /**
-        * Resolves the command by its direct name and returns an instance of its class
-        *
-        * @param       $commandName            The direct command name we shall resolve
-        * @return      $commandInstance        An instance of the command class
-        * @throws      InvalidCommandException         Thrown if $commandName is invalid
-        */
-       public function resolveCommand ($commandName) {
-               // Initiate the instance variable
-               $commandInstance = null;
-
-               // Is the command empty? Then fall back to default command
-               if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_web_command');
-
-               // Check if command is valid
-               if ($this->isCommandValid($commandName) === false) {
-                       // This command is invalid!
-                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-               }
-
-               // Get the command
-               $commandInstance = $this->loadCommand($commandName);
-
-               // Return the instance
-               return $commandInstance;
-       }
-
-       /**
-        * "Loads" a given command and instances it if not yet cached
-        *
-        * @param       $commandName                            A command name we shall look for
-        * @return      $commandInstance                        A loaded command instance
-        * @throws      InvalidCommandException         Thrown if even the default
-        *                                                                              command class is missing (bad!)
-        */
-       private function loadCommand ($commandName) {
-               // Cache default command
-               $defaultCommand = $this->getConfigInstance()->getConfigEntry('default_web_command');
-
-               // Init command instance
-               $commandInstance = null;
-
-               // Get 'app' from the application
-               $app = Registry::getRegistry()->getInstance('application')->getRequestInstance()->getRequestElement('app');
-
-               // Create command class name
-               $this->setClassName(sprintf('%s%sCommand',
-                       $this->getCommandPrefix(),
-                       $this->convertToClassName($commandName)
-               ));
-
-               // Is this class loaded?
-               if (!class_exists($this->getClassName())) {
-                       // Class not found, so throw an exception
-                       throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
-               } // END - if
-
-               // Initiate the command
-               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
-
-               // Return the result
-               return $commandInstance;
-       }
 }
 
 // [EOF]
index a83f2225ba983f3f3fae1dde0cd953320f856265..16edb506c1ce7958f1ff1e1ad1cf2cce6d8ecaf3 100644 (file)
@@ -37,7 +37,7 @@ class HtmlGovernmentFailedCommandResolver extends BaseCommandResolver implements
                parent::__construct(__CLASS__);
 
                // Set prefix to "Html"
-               $this->setCommandPrefix('Html');
+               $this->setCommandPrefix('html');
        }
 
        /**
@@ -71,116 +71,6 @@ class HtmlGovernmentFailedCommandResolver extends BaseCommandResolver implements
                // Return the prepared instance
                return $resolverInstance;
        }
-
-       /**
-        * Returns an command instance for a given request class or null if
-        * it was not found
-        *
-        * @param       $requestInstance        An instance of a request class
-        * @return      $commandInstance        An instance of the resolved command
-        * @throws      InvalidCommandException                         Thrown if $commandName is
-        *                                                                                              invalid
-        * @throws      InvalidCommandInstanceException         Thrown if $commandInstance
-        *                                                                                              is an invalid instance
-        */
-       public function resolveCommandByRequest (Requestable $requestInstance) {
-               // Init instance
-               $commandInstance = null;
-
-               // This goes fine so let's resolv the command
-               $commandName = $requestInstance->getRequestElement('page');
-
-               // Is there a "failed" request?
-               if ($requestInstance->isRequestElementSet('failed')) {
-                       // Then include with within the command name
-                       $commandName = sprintf('%s_%s', $commandName, $requestInstance->getRequestElement('failed'));
-               } // END - if
-
-               // Is the command empty? Then fall back to default command
-               if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_web_command');
-
-               // Check if command is valid
-               if ($this->isCommandValid($commandName) === false) {
-                       // This command is invalid!
-                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-               } // END - if
-
-               // Get the command
-               $commandInstance = $this->loadCommand($commandName);
-
-               // And validate it
-               if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
-                       // This command has an invalid instance!
-                       throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-               } // END - if
-
-               // Set last command
-               $this->lastCommandInstance = $commandInstance;
-
-               // Return the resolved command instance
-               return $commandInstance;
-       }
-
-       /**
-        * Resolves the command by its direct name and returns an instance of its class
-        *
-        * @param       $commandName            The direct command name we shall resolve
-        * @return      $commandInstance        An instance of the command class
-        * @throws      InvalidCommandException         Thrown if $commandName is invalid
-        */
-       public function resolveCommand ($commandName) {
-               // Initiate the instance variable
-               $commandInstance = null;
-
-               // Is the command empty? Then fall back to default command
-               if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_web_command');
-
-               // Check if command is valid
-               if ($this->isCommandValid($commandName) === false) {
-                       // This command is invalid!
-                       throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
-               }
-
-               // Get the command
-               $commandInstance = $this->loadCommand($commandName);
-
-               // Return the instance
-               return $commandInstance;
-       }
-
-       /**
-        * "Loads" a given command and instances it if not yet cached
-        *
-        * @param       $commandName                            A command name we shall look for
-        * @return      $commandInstance                        A loaded command instance
-        * @throws      InvalidCommandException         Thrown if even the default
-        *                                                                              command class is missing (bad!)
-        */
-       private function loadCommand ($commandName) {
-               // Cache default command
-               $defaultCommand = $this->getConfigInstance()->getConfigEntry('default_web_command');
-
-               // Init command instance
-               $commandInstance = null;
-
-               // Create command class name
-               $this->setClassName(sprintf('%s%sCommand',
-                       $this->getCommandPrefix(),
-                       $this->convertToClassName($commandName)
-               ));
-
-               // Is this class loaded?
-               if (!class_exists($this->getClassName())) {
-                       // Class not found, so throw an exception
-                       throw new InvalidCommandException(array($this, $defaultCommand), self::EXCEPTION_INVALID_COMMAND);
-               } // END - if
-
-               // Initiate the command
-               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
-
-               // Return the result
-               return $commandInstance;
-       }
 }
 
 // [EOF]
diff --git a/core b/core
index a142fe5eeaaa17a434c80ea103088558157c43bb..b84edaf9f45857dea7078c230cea0290089c0770 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit a142fe5eeaaa17a434c80ea103088558157c43bb
+Subproject commit b84edaf9f45857dea7078c230cea0290089c0770