]> git.mxchange.org Git - shipsimu.git/commitdiff
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 57f3ab728de3130f962d9f35085bbfccee32bbd7..b9367f2832007fa0d88ef5cea18de03ca1bc6b06 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/.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_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
 application/ship-simu/main/bank/.htaccess -text
 application/ship-simu/main/bank/class_MoneyBank.php -text
 application/ship-simu/main/class_ -text
index f6cb95ee08cf7f4622404bdcffd172a7726135c5..99b2e56dfa88855d5a72bd109fa79f9f5862be23 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
         * @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
         */
        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
         * @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) {
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // Add user status filter here
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+               // Unfinished method
        }
 }
 
        }
 }
 
index e416055579d659efbf87572a5bdf462be3d579be..e4c3ed997b63b32c83d9d8c1f35412e2958d685b 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
         * @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) {
         */
        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 fc25b9501d853d7a06de9fc7cfc3f5cd259e8f10..8d02747ef8b4ee2b753d0e5c0a605e2db397920a 100644 (file)
@@ -69,9 +69,6 @@ class WebShipSimuLoginRefillAction extends BaseAction implements Commandable, Re
         * @return      void
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
         * @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'));
 
                // 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 addebdb1d7c7c518c3292c038baf388c25b567ea..96c1b73aeca5d35462cfce80edd09c11712cc184 100644 (file)
@@ -31,10 +31,11 @@ class InvalidActionException extends FrameworkException {
         */
        public function __construct(array $msgArray, $code) {
                // Prepare the message
         */
        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[0]->__toString(),
                        $this->getLine(),
-                       $msgArray[1]
+                       $msgArray[1],
+                       $msgArray[0]->getClassName()
                );
 
                // Call parent contructor with message
                );
 
                // Call parent contructor with message
index 267744c2556d2ec651d03e188418f9287a01bb93..31a7ba642df74aa2b33ab1d0e267c822488efb5f 100644 (file)
@@ -61,9 +61,18 @@ abstract class FrameworkException extends ReflectionException {
                        // End here
                        exit;
                } // END - if
                        // End here
                        exit;
                } // END - if
-
                // Make sure everything is assigned properly
                parent::__construct($message, $code);
                // 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 3149a25d9f88930caedf713ffcf64fbba9049031..98f76cd104db292415ac67d0358bd206958f0886 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
         *
         * @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();
 
                // 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 f4ce05334afb2020b4fe2dfc74de7cffa7f3b83b..83964d2508b7902a170cf4aed740cdee2563ad18 100644 (file)
@@ -47,6 +47,12 @@ class WebLoginController extends BaseController implements Controller {
                // Set the command resolver
                $controllerInstance->setResolverInstance($resolverInstance);
 
                // 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;
        }
                // Return the prepared instance
                return $controllerInstance;
        }
index 9e927712f22c47442dd5952eda23b5c8be3a1988..250fa014044db78476de073e4152888d7695d556 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
         * "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
         */
        protected function loadAction () {
                // Init action instance