From: Roland Haeder Date: Tue, 24 Mar 2015 19:27:36 +0000 (+0100) Subject: Class prefixes for actions, commands and controllers can now be like 'foo_bar'. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4d615586b509f817b35e8d1f0388dc9b4e543d9a;p=core.git Class prefixes for actions, commands and controllers can now be like 'foo_bar'. Signed-off-by: Roland Häder --- diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php index f6fa4351..c8daf001 100644 --- a/inc/classes/main/resolver/action/class_BaseActionResolver.php +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -75,7 +75,7 @@ class BaseActionResolver extends BaseResolver { } // END - if // Create class name - $className = $this->getClassPrefix() . $this->convertToClassName($actionName) . 'Action'; + $className = $this->getCapitalizedClassPrefix() . $this->convertToClassName($actionName) . 'Action'; // Now, let us create the full name of the action class $this->setClassName($className); @@ -103,7 +103,7 @@ class BaseActionResolver extends BaseResolver { $actionInstance = NULL; // Create action class name - $className = $this->getClassPrefix() . $this->convertToClassName($this->getActionName()) . 'Action'; + $className = $this->getCapitalizedClassPrefix() . $this->convertToClassName($this->getActionName()) . 'Action'; // ... and set it $this->setClassName($className); diff --git a/inc/classes/main/resolver/class_BaseResolver.php b/inc/classes/main/resolver/class_BaseResolver.php index 4ed9dfb8..1e9274f2 100644 --- a/inc/classes/main/resolver/class_BaseResolver.php +++ b/inc/classes/main/resolver/class_BaseResolver.php @@ -63,6 +63,22 @@ class BaseResolver extends BaseFrameworkSystem { return $this->className; } + /** + * "Getter" for class name (useable for an object factory) + * + * @return $className Capitalized class name + */ + protected function getCapitalizedClassPrefix () { + // Get class name + $className = $this->getClassPrefix(); + + // And capitalize it + $className = $this->convertToClassName($className); + + // Return it + return $className; + } + /** * Setter for class name * diff --git a/inc/classes/main/resolver/command/class_BaseCommandResolver.php b/inc/classes/main/resolver/command/class_BaseCommandResolver.php index 9446ed89..4d027b37 100644 --- a/inc/classes/main/resolver/command/class_BaseCommandResolver.php +++ b/inc/classes/main/resolver/command/class_BaseCommandResolver.php @@ -75,7 +75,7 @@ class BaseCommandResolver extends BaseResolver { } // END - if // Create the full class name - $className = $this->getClassPrefix() . $this->convertToClassName($commandName) . 'Command'; + $className = $this->getCapitalizedClassPrefix() . $this->convertToClassName($commandName) . 'Command'; // Now, let us create the full name of the command class $this->setClassName($className); diff --git a/inc/classes/main/resolver/command/console/class_ConsoleCommandResolver.php b/inc/classes/main/resolver/command/console/class_ConsoleCommandResolver.php index 079005b9..ea1024be 100644 --- a/inc/classes/main/resolver/command/console/class_ConsoleCommandResolver.php +++ b/inc/classes/main/resolver/command/console/class_ConsoleCommandResolver.php @@ -152,7 +152,7 @@ class ConsoleCommandResolver extends BaseCommandResolver implements CommandResol $commandInstance = NULL; // Create class name - $className = $this->getClassPrefix() . $this->convertToClassName($commandName) . 'Command'; + $className = $this->getCapitalizedClassPrefix() . $this->convertToClassName($commandName) . 'Command'; // Create command class name $this->setClassName($className); diff --git a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php index 6f4b1d2a..b0fc8be6 100644 --- a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php +++ b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php @@ -157,7 +157,7 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve $commandInstance = NULL; // Create class name - $className = $this->getClassPrefix() . $this->convertToClassName($commandName) . 'Command'; + $className = $this->getCapitalizedClassPrefix() . $this->convertToClassName($commandName) . 'Command'; // Is this class loaded? if (!class_exists($this->getClassName())) { diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php index 3b2e4433..03560545 100644 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -75,19 +75,19 @@ class BaseControllerResolver extends BaseResolver { $controllerInstance = NULL; // Default controller - $this->setClassName($this->getClassPrefix() . 'DefaultNewsController'); + $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); // Generate the class name //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BEFORE: controller=' . $controllerName); if ($controllerName != $defaultController) { // Create controller class name - $className = $this->getClassPrefix() . $this->convertToClassName($controllerName) . 'Controller'; + $className = $this->getCapitalizedClassPrefix() . $this->convertToClassName($controllerName) . 'Controller'; // ... and set it $this->setClassName($className); } else { // No news at main command or non-news command - $this->setClassName($this->getClassPrefix() . 'DefaultNewsController'); + $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); } //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('AFTER: controller=' . $this->getClassName()); @@ -142,7 +142,7 @@ class BaseControllerResolver extends BaseResolver { } // END - if // Create class name - $className = $this->getClassPrefix() . $this->convertToClassName($controllerName) . 'Controller'; + $className = $this->getCapitalizedClassPrefix() . $this->convertToClassName($controllerName) . 'Controller'; // Now, let us create the full name of the controller class $this->setClassName($className); @@ -153,9 +153,9 @@ class BaseControllerResolver extends BaseResolver { if (class_exists($this->getClassName())) { // This class does exist. :-) $isValid = TRUE; - } elseif ($this->getClassName() != $this->getClassPrefix() . 'DefaultNewsController') { + } elseif ($this->getClassName() != $this->getCapitalizedClassPrefix() . 'DefaultNewsController') { // Set default controller - $this->setClassName($this->getClassPrefix() . 'DefaultNewsController'); + $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); } else { // All is tried, give it up here throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE);