]> git.mxchange.org Git - shipsimu.git/commitdiff
Filters added no longer in command constructor
authorRoland Häder <roland@mxchange.org>
Fri, 20 Jun 2008 17:36:10 +0000 (17:36 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 20 Jun 2008 17:36:10 +0000 (17:36 +0000)
application/ship-simu/exceptions.php
application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php
application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php
application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php
application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php

index 98989ee11b992d4e64f4dd16443e53d3e361089f..6d606d9be93a8a8e4af0bdd36ef01b16abebb2b7 100644 (file)
 // Our own exception handler
 function __exceptionHandler (FrameworkException $e) {
        // Call the app_die() method
-       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> (<strong>%s</strong>) has been terminated due to a thrown exception: <strong>%s: <span id=\"debug_exception\">%s</em></strong>. Backtrace: <div id=\"debug_backtrace\">%s</div>",
+       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> (<strong>%s</strong>) has been terminated due to a thrown exception: <strong>%s[%s]: <span id=\"debug_exception\">%s</em></strong>. Backtrace: <div id=\"debug_backtrace\">%s</div>",
                ApplicationHelper::getInstance()->getAppName(),
                ApplicationHelper::getInstance()->getAppShortName(),
                $e->__toString(),
+               $e->getHexCode(),
                $e->getMessage(),
                $e->getPrintableBackTrace()
        ));
index 60d7fa93bccc978c28a4c9f8d26fc32321201ff0..0c9e6cbe60e1e156613eea9e5c3562a648e39551 100644 (file)
@@ -55,26 +55,6 @@ class WebShipsimuGuestLoginCommand extends BaseCommand implements Commandable {
                // Set the resolver instance
                $commandInstance->setResolverInstance($resolverInstance);
 
-               // Get the controller instance from the resolver (breaks MVC pattern again)
-               $controllerInstance = $resolverInstance->getControllerInstance();
-
-               switch ($commandInstance->getConfigInstance()->readConfig('login_type')) {
-                       case "username": // Login via username
-                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class'));
-                               break;
-
-                       case "email": // Login via email
-                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_class'));
-                               break;
-
-                       default: // Wether username or email is set
-                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_class'));
-                               break;
-               }
-
-               /* @TODO Add more filters */
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_class'));
-
                // Return the prepared instance
                return $commandInstance;
        }
@@ -121,7 +101,23 @@ class WebShipsimuGuestLoginCommand extends BaseCommand implements Commandable {
         * @return      void
         */
        function addExtraFilters (Controller $controllerInstance) {
-               // Empty for now
+               // Which login type do we have?
+               switch ($commandInstance->getConfigInstance()->readConfig('login_type')) {
+                       case "username": // Login via username
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class'));
+                               break;
+
+                       case "email": // Login via email
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_class'));
+                               break;
+
+                       default: // Wether username or email is set
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_class'));
+                               break;
+               }
+
+               /* @TODO Add more filters */
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_class'));
        }
 }
 
index 18adfa07126ac6df9f36aceda90d65854fbab076..3fa1529ae48a5b56b76afc15f2d40f370c1aeb64 100644 (file)
@@ -79,14 +79,6 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable {
                // Set the resolver instance
                $commandInstance->setResolverInstance($resolverInstance);
 
-               // Get the controller instance from the resolver (breaks MVC pattern again)
-               $controllerInstance = $resolverInstance->getControllerInstance();
-
-               /* @TODO Add some more pre/post filters to the controller */
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_change_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_change_class'));
-
                // Return the prepared instance
                return $commandInstance;
        }
@@ -101,13 +93,19 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable {
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Make sure only allowed values are comming through
                foreach ($this->allowedData as $alias=>$element) {
+                       // Get data
+                       $data = $requestInstance->getRequestElement($element);
+
+                       // Skip empty fields
+                       if (empty($data)) continue;
+
                        // Do we have an alias?
                        if (is_string($alias)) {
                                // Yes, so use it
-                               $this->requestData[$alias]   = $requestInstance->getRequestElement($element);
+                               $this->requestData[$alias]   = $data;
                        } else {
                                // No, default entry
-                               $this->requestData[$element] = $requestInstance->getRequestElement($element);
+                               $this->requestData[$element] = $data;
                        }
                } // END - foreach
 
@@ -127,6 +125,11 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable {
        function addExtraFilters (Controller $controllerInstance) {
                // 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_class'));
+
+               /* @TODO Add some more pre/post filters to the controller */
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_change_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_change_class'));
        }
 }
 
index 3958ea587ec91b4fb3de788eb2853ef25a009390..61c537aa6d7bf8fdeaf666cc345a53b0b0fb610c 100644 (file)
@@ -55,16 +55,6 @@ class WebShipsimuRegisterCommand extends BaseCommand implements Commandable {
                // Set the resolver instance
                $commandInstance->setResolverInstance($resolverInstance);
 
-               // Get the controller instance from the resolver (breaks MVC pattern again)
-               $controllerInstance = $resolverInstance->getControllerInstance();
-
-               /* @TODO Add some more pre/post filters to the controller */
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_is_guest_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_validator_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_class'));
-
                // Return the prepared instance
                return $commandInstance;
        }
@@ -108,7 +98,12 @@ class WebShipsimuRegisterCommand extends BaseCommand implements Commandable {
         * @return      void
         */
        function addExtraFilters (Controller $controllerInstance) {
-               // Empty for now
+               /* @TODO Add some more pre/post filters to the controller */
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_is_guest_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_validator_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_class'));
        }
 }
 
index 908d1f117156800e303368a63ea7ce63380165e2..3721c08e73321ee8904cd6edd7433b77c554ffde 100644 (file)
@@ -55,26 +55,6 @@ class WebShipsimuUserLoginCommand extends BaseCommand implements Commandable {
                // Set the resolver instance
                $commandInstance->setResolverInstance($resolverInstance);
 
-               // Get the controller instance from the resolver (breaks MVC pattern again)
-               $controllerInstance = $resolverInstance->getControllerInstance();
-
-               switch ($commandInstance->getConfigInstance()->readConfig('login_type')) {
-                       case "username": // Login via username
-                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class'));
-                               break;
-
-                       case "email": // Login via email
-                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_class'));
-                               break;
-
-                       default: // Wether username or email is set
-                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_class'));
-                               break;
-               }
-
-               /* @TODO Add more filters */
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_class'));
-
                // Return the prepared instance
                return $commandInstance;
        }
@@ -121,7 +101,23 @@ class WebShipsimuUserLoginCommand extends BaseCommand implements Commandable {
         * @return      void
         */
        function addExtraFilters (Controller $controllerInstance) {
-               // Empty for now
+               // Which login type do we have?
+               switch ($commandInstance->getConfigInstance()->readConfig('login_type')) {
+                       case "username": // Login via username
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class'));
+                               break;
+
+                       case "email": // Login via email
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_class'));
+                               break;
+
+                       default: // Wether username or email is set
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_class'));
+                               break;
+               }
+
+               /* @TODO Add more filters */
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_class'));
        }
 }