]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/resolver/command/class_BaseCommandResolver.php
Continued:
[core.git] / framework / main / classes / resolver / command / class_BaseCommandResolver.php
index f064b30ffe8a4cfd0c5b549e2c49f6cf80b457e8..98c3a81e3dc19d1ec7286881a49a22a3f911976e 100644 (file)
@@ -37,17 +37,41 @@ use \UnexpectedValueException;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseCommandResolver extends BaseResolver {
+       /**
+        * Command name
+        */
+       private $commandName = '';
+
        /**
         * Protected constructor
         *
         * @param       $className      Name of the class
         * @return      void
         */
-       protected function __construct ($className) {
+       protected function __construct (string $className) {
                // Call parent constructor
                parent::__construct($className);
        }
 
+       /**
+        * Setter for command name
+        *
+        * @param       $commandName    Last validated command name
+        * @return      void
+        */
+       protected final function setCommandName (string $commandName) {
+               $this->commandName = $commandName;
+       }
+
+       /**
+        * Getter for command name
+        *
+        * @return      $commandName    Last validated command name
+        */
+       protected final function getCommandName () {
+               return $this->commandName;
+       }
+
        /**
         * "Loads" a given command and instances it if not yet cached
         *
@@ -103,7 +127,7 @@ abstract class BaseCommandResolver extends BaseResolver {
 
                // Is the command empty? Then fall back to default command
                if (empty($commandName)) {
-                       $commandName = $this->getConfigInstance()->getConfigEntry('default_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command');
+                       $commandName = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command');
                } // END - if
 
                // Check if command is valid
@@ -152,7 +176,7 @@ abstract class BaseCommandResolver extends BaseResolver {
                // Is the command empty? Then fall back to default command
                if (empty($commandName)) {
                        // Init default command
-                       $commandName = $this->getConfigInstance()->getConfigEntry('default_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command');
+                       $commandName = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command');
                } // END - if
 
                // Check if command is valid
@@ -177,9 +201,6 @@ abstract class BaseCommandResolver extends BaseResolver {
         * @throws      InvalidArgumentException        Thrown if given command is not set
         */
        protected function isCommandValid ($namespace, $commandName) {
-               // By default nothing shall be valid
-               $isValid = false;
-
                // Is namespace and command name set?
                if (empty($namespace)) {
                        // Then thrown an exception here
@@ -187,7 +208,10 @@ abstract class BaseCommandResolver extends BaseResolver {
                } elseif (empty($commandName)) {
                        // Then thrown an exception here
                        throw new InvalidArgumentException('Parameter "commandName" is empty');
-               } // END - if
+               }
+
+               // By default nothing shall be valid
+               $isValid = false;
 
                // Create the full class name
                $className = sprintf(