From 83ceb6f4eb20c78b5e83842bf3bb84cd5758a647 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 5 Mar 2011 12:35:18 +0000 Subject: [PATCH] Directory prepared, missing variable fixed: - Added missing class template for resolver class - Prepared directory for request resolver (the method entryPoint() is to large) - Fixed missing variable $result in method equals() --- .gitattributes | 2 + .../main/class_BaseFrameworkSystem.php | 2 +- inc/classes/main/resolver/class_ | 576 ++++++++++++++++++ inc/classes/main/resolver/request/.htaccess | 4 + inc/config/class_FrameworkConfiguration.php | 2 +- 5 files changed, 584 insertions(+), 2 deletions(-) create mode 100644 inc/classes/main/resolver/class_ create mode 100644 inc/classes/main/resolver/request/.htaccess diff --git a/.gitattributes b/.gitattributes index e344bcca..2f1dff57 100644 --- a/.gitattributes +++ b/.gitattributes @@ -470,6 +470,7 @@ inc/classes/main/resolver/action/.htaccess -text svneol=unset#text/plain inc/classes/main/resolver/action/class_BaseActionResolver.php -text svneol=unset#text/plain inc/classes/main/resolver/action/web/.htaccess -text svneol=unset#text/plain inc/classes/main/resolver/action/web/class_WebActionResolver.php -text svneol=unset#text/plain +inc/classes/main/resolver/class_ -text inc/classes/main/resolver/class_BaseResolver.php -text svneol=unset#text/plain inc/classes/main/resolver/command/.htaccess -text svneol=unset#text/plain inc/classes/main/resolver/command/class_BaseCommandResolver.php -text svneol=unset#text/plain @@ -488,6 +489,7 @@ inc/classes/main/resolver/controller/image/.htaccess -text svneol=unset#text/pla inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php -text svneol=unset#text/plain inc/classes/main/resolver/controller/web/.htaccess -text svneol=unset#text/plain inc/classes/main/resolver/controller/web/class_WebControllerResolver.php -text svneol=unset#text/plain +inc/classes/main/resolver/request/.htaccess svneol=native#text/plain inc/classes/main/response/.htaccess -text svneol=unset#text/plain inc/classes/main/response/class_BaseResponse.php -text svneol=unset#text/plain inc/classes/main/response/console/.htaccess -text svneol=unset#text/plain diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 7fa4374d..9b153224 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -595,7 +595,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { )); // Return the result - return $result; + return $equals; } /** diff --git a/inc/classes/main/resolver/class_ b/inc/classes/main/resolver/class_ new file mode 100644 index 00000000..5d4fb171 --- /dev/null +++ b/inc/classes/main/resolver/class_ @@ -0,0 +1,576 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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 . + */ +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 Web 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] +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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 . + */ +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 Web 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] +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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 . + */ +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 Web 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] +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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 . + */ +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 Web 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] +?> diff --git a/inc/classes/main/resolver/request/.htaccess b/inc/classes/main/resolver/request/.htaccess new file mode 100644 index 00000000..0a9de16e --- /dev/null +++ b/inc/classes/main/resolver/request/.htaccess @@ -0,0 +1,4 @@ +Deny from all +Deny from all +Deny from all +Deny from all diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 7e93e21b..c69bd5ef 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -335,7 +335,7 @@ class FrameworkConfiguration implements Registerable { )); // Return the result - return $result; + return $equals; } } -- 2.39.2