/**
* Returns an command instance for a given request class or null if
- * MissingArrayElementsException was thrown
+ * it was not found
*
* @param $requestInstance An instance of a request class
* @return $commandInstance An instance of the resolved command
$commandName = "";
$commandInstance = null;
- // Test if the required parameter is set
- try {
- // This goes fine so let's resolv the command
- $commandName = $requestInstance->getRequestElement("page");
+ // This goes fine so let's resolv the command
+ $commandName = $requestInstance->getRequestElement("page");
- // Is the command empty? Then fall back to default command
- if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_command');
+ // Is the command empty? Then fall back to default command
+ if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_command');
- // Check if the command is valid
- if (!$this->isCommandValid($commandName)) {
- // This command is invalid!
- throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
- }
+ // Check if the command is valid
+ if (!$this->isCommandValid($commandName)) {
+ // This command is invalid!
+ throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ } // END - if
- // Get the command
- $commandInstance = $this->loadCommand($commandName);
+ // 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);
- }
+ // 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;
- } catch (MissingArrayElementsException $e) {
- // Just catch it here...
- }
+ // Set last command
+ $this->lastCommandInstance = $commandInstance;
// Return the resolved command instance
return $commandInstance;