A performed action now always requires an action class
authorRoland Häder <roland@mxchange.org>
Fri, 14 Nov 2008 21:39:09 +0000 (21:39 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 14 Nov 2008 21:39:09 +0000 (21:39 +0000)
.gitattributes
application/ship-simu/main/actions/web/class_WebShipSimuLogin
application/ship-simu/main/actions/web/class_WebShipSimuLoginCompanyAction.php
application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php [new file with mode: 0644]
application/ship-simu/main/actions/web/class_WebShipSimuLoginRefillAction.php
application/ship-simu/main/actions/web/class_WebShipSimuLoginWelcomeAction.php [new file with mode: 0644]
inc/classes/exceptions/actions/class_InvalidActionException.php
inc/classes/exceptions/class_FrameworkException.php
inc/classes/main/commands/web/class_WebLoginAreaCommand.php
inc/classes/main/controller/web/class_WebLoginController.php
inc/classes/main/resolver/action/class_BaseActionResolver.php

index 57f3ab7..b9367f2 100644 (file)
@@ -165,7 +165,9 @@ application/ship-simu/main/actions/ship-simu/class_ShipSimuProfileAction.php -te
 application/ship-simu/main/actions/web/.htaccess -text
 application/ship-simu/main/actions/web/class_WebShipSimuLogin -text
 application/ship-simu/main/actions/web/class_WebShipSimuLoginCompanyAction.php -text
+application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php -text
 application/ship-simu/main/actions/web/class_WebShipSimuLoginRefillAction.php -text
+application/ship-simu/main/actions/web/class_WebShipSimuLoginWelcomeAction.php -text
 application/ship-simu/main/bank/.htaccess -text
 application/ship-simu/main/bank/class_MoneyBank.php -text
 application/ship-simu/main/class_ -text
index f6cb95e..99b2e56 100644 (file)
@@ -55,7 +55,7 @@ class WebShipSimuLogin???Action extends BaseAction implements Commandable, Regis
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @todo        Maybe add fetching company list of current user here?
+        * @todo        0% done
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Unfinished method
@@ -67,10 +67,10 @@ class WebShipSimuLogin???Action extends BaseAction implements Commandable, Regis
         * @param       $controllerInstance             A controller instance
         * @param       $requestInstance                An instance of a class with an Requestable interface
         * @return      void
+        * @todo        Add some filters here
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // Add user status filter here
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+               // Unfinished method
        }
 }
 
index e416055..e4c3ed9 100644 (file)
@@ -67,10 +67,10 @@ class WebShipSimuLoginCompanyAction extends BaseAction implements Commandable, R
         * @param       $controllerInstance             A controller instance
         * @param       $requestInstance                An instance of a class with an Requestable interface
         * @return      void
+        * @todo        Add some filters here
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // Add user status filter here
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+               // Unfinished method
        }
 }
 
diff --git a/application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php b/application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php
new file mode 100644 (file)
index 0000000..fed0d1d
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * An action for logout
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class WebShipSimuLoginLogoutAction extends BaseAction implements Commandable, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this action
+        *
+        * @param       $resolverInstance       An instance of an action resolver
+        * @return      $actionInstance         An instance of this action class
+        */
+       public final static function createWebShipSimuLoginLogoutAction (ActionResolver $resolverInstance) {
+               // Get a new instance
+               $actionInstance = new WebShipSimuLoginLogoutAction();
+
+               // Set the resolver instance
+               $actionInstance->setResolverInstance($resolverInstance);
+
+               // Return the instance
+               return $actionInstance;
+       }
+
+       /**
+        * Executes the command with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Unfinished method
+       }
+
+       /**
+        * Adds extra filters to the given controller instance
+        *
+        * @param       $controllerInstance             A controller instance
+        * @param       $requestInstance                An instance of a class with an Requestable interface
+        * @return      void
+        */
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+       }
+}
+
+// [EOF]
+?>
index fc25b95..8d02747 100644 (file)
@@ -69,9 +69,6 @@ class WebShipSimuLoginRefillAction extends BaseAction implements Commandable, Re
         * @return      void
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // Add user status filter here
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
-
                // Is the refill page active?
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('refill_page_filter'));
 
diff --git a/application/ship-simu/main/actions/web/class_WebShipSimuLoginWelcomeAction.php b/application/ship-simu/main/actions/web/class_WebShipSimuLoginWelcomeAction.php
new file mode 100644 (file)
index 0000000..64f60b9
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/**
+ * An action for the welcome page
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class WebShipSimuLoginWelcomeAction extends BaseAction implements Commandable, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this action
+        *
+        * @param       $resolverInstance       An instance of an action resolver
+        * @return      $actionInstance         An instance of this action class
+        */
+       public final static function createWebShipSimuLoginWelcomeAction (ActionResolver $resolverInstance) {
+               // Get a new instance
+               $actionInstance = new WebShipSimuLoginWelcomeAction();
+
+               // Set the resolver instance
+               $actionInstance->setResolverInstance($resolverInstance);
+
+               // Return the instance
+               return $actionInstance;
+       }
+
+       /**
+        * Executes the command with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Unfinished method
+       }
+
+       /**
+        * Adds extra filters to the given controller instance
+        *
+        * @param       $controllerInstance             A controller instance
+        * @param       $requestInstance                An instance of a class with an Requestable interface
+        * @return      void
+        * @todo        Add some filters here
+        */
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+               // Unfinished method
+       }
+}
+
+// [EOF]
+?>
index addebdb..96c1b73 100644 (file)
@@ -31,10 +31,11 @@ class InvalidActionException extends FrameworkException {
         */
        public function __construct(array $msgArray, $code) {
                // Prepare the message
-               $message = sprintf("[%s:%d] Cannot resolve action <span class=\"exception_reason\">%s</span>.",
+               $message = sprintf("[%s:%d] Cannot resolve action <span class=\"exception_reason\">%s (%s)</span>.",
                        $msgArray[0]->__toString(),
                        $this->getLine(),
-                       $msgArray[1]
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
                );
 
                // Call parent contructor with message
index 267744c..31a7ba6 100644 (file)
@@ -61,9 +61,18 @@ abstract class FrameworkException extends ReflectionException {
                        // End here
                        exit;
                } // END - if
-
                // Make sure everything is assigned properly
                parent::__construct($message, $code);
+
+               // Log it away if DEBUG_ALL is set
+               if (defined('DEBUG_ALL')) {
+                       // Log the error
+                       error_log(sprintf("[%s:] %s (%s)",
+                               $this->__toString(),
+                               $message,
+                               $this->getHexCode()
+                       ));
+               } // END - if
        }
 
        /**
index 3149a25..98f76cd 100644 (file)
@@ -142,7 +142,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
        }
 
        /**
-        * Adds extra filters to the given controller instance
+        * Adds extra filters to the given controller instance. An corresponding action class must now exist!
         *
         * @param       $controllerInstance             A controller instance
         * @param       $requestInstance                An instance of a class with an Requestable interface
@@ -179,22 +179,17 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                // Get application instance
                $applicationInstance = $this->getResolverInstance()->getApplicationInstance();
 
-               // Try to get an action resolver for the given action
-               try {
-                       // Get a resolver
-                       $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance);
+               // Get a resolver
+               $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance);
 
-                       // Resolve the action
-                       $actionInstance = $actionResolver->resolveAction();
+               // Resolve the action
+               $actionInstance = $actionResolver->resolveAction();
 
-                       // Add more action-specific filters
-                       $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
+               // Add more action-specific filters
+               $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
 
-                       // Remember this action in registry
-                       Registry::getRegistry()->addInstance('action', $actionInstance);
-               } catch (InvalidActionException $e) {
-                       // Silently ignored because no special action was found
-               }
+               // Remember this action in registry
+               Registry::getRegistry()->addInstance('action', $actionInstance);
        }
 }
 
index f4ce053..83964d2 100644 (file)
@@ -47,6 +47,12 @@ class WebLoginController extends BaseController implements Controller {
                // Set the command resolver
                $controllerInstance->setResolverInstance($resolverInstance);
 
+               // Add user auth filter (we don't need an update of the user here because it will be redirected)
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
+
+               // Check for user status by default
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+
                // Return the prepared instance
                return $controllerInstance;
        }
index 9e92771..250fa01 100644 (file)
@@ -112,8 +112,6 @@ class BaseActionResolver extends BaseResolver {
         * "Loads" current action and instances it if not yet cached
         *
         * @return      $actionInstance                 A loaded action instance
-        * @throws      InvalidActionException  Thrown if even the default
-        *                                                                      action class is missing (bad!)
         */
        protected function loadAction () {
                // Init action instance