X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fresolver%2Faction%2Fclass_BaseActionResolver.php;h=44836e9d52be1000b3b51f6c4097f78a448f11d4;hb=948e194bc84bf2219426dc56ad7481d04cd82374;hp=6f4cbd83271cd761c2964ffa1234d5b72ea93a59;hpb=361e6320e50a8bb1a3ccb675388b8042361669ae;p=core.git diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php index 6f4cbd83..44836e9d 100644 --- a/inc/classes/main/resolver/action/class_BaseActionResolver.php +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -2,11 +2,11 @@ /** * A generic action resolver class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.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 @@ -22,15 +22,10 @@ * along with this program. If not, see . */ class BaseActionResolver extends BaseResolver { - /** - * Prefix for local, remote or other resolver - */ - private $actionPrefix = ""; - /** * Validated action name */ - private $actionName = ""; + private $actionName = ''; /** * Protected constructor @@ -43,16 +38,6 @@ class BaseActionResolver extends BaseResolver { parent::__construct($className); } - /** - * Setter for action prefix - * - * @param $actionPrefix Last validated actionPrefix - * @return void - */ - protected final function setActionPrefix ($actionPrefix) { - $this->actionPrefix = $actionPrefix; - } - /** * Setter for action name * @@ -73,15 +58,15 @@ class BaseActionResolver extends BaseResolver { } /** - * Checks wether the given action is valid + * Checks whether the given action is valid * * @param $actionName The default action we shall execute - * @return $isValid Wether the given action is valid + * @return $isValid Whether the given action is valid * @throws EmptyVariableException Thrown if given action is not set */ public function isActionValid ($actionName) { // By default nothing shall be valid - $isValid = false; + $isValid = FALSE; // Is a action set? if (empty($actionName)) { @@ -89,16 +74,16 @@ class BaseActionResolver extends BaseResolver { throw new EmptyVariableException(array($this, 'actionName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); } // END - if + // Create class name + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($actionName) . 'Action'; + // Now, let us create the full name of the action class - $this->setClassName(sprintf("%s%sAction", - $this->actionPrefix, - $this->convertToClassName($actionName) - )); + $this->setClassName($className); // Is this class already loaded? if (class_exists($this->getClassName())) { // This class does exist. :-) - $isValid = true; + $isValid = TRUE; } // END - if // Set action name @@ -115,12 +100,13 @@ class BaseActionResolver extends BaseResolver { */ protected function loadAction () { // Init action instance - $actionInstance = null; + $actionInstance = NULL; // Create action class name - $this->setClassName(sprintf("Web%sAction", - $this->convertToClassName($this->getActionName()) - )); + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($this->getActionName()) . 'Action'; + + // ... and set it + $this->setClassName($className); // Initiate the action $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));