From 495b289c89510c0a56651ff439055cffd35d1f89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 20 Jun 2008 17:36:10 +0000 Subject: [PATCH] Filters added no longer in command constructor --- application/ship-simu/exceptions.php | 3 +- .../class_WebShipsimuGuestLoginCommand.php | 38 +++++++++---------- .../web/class_WebShipsimuProfileCommand.php | 23 ++++++----- .../web/class_WebShipsimuRegisterCommand.php | 17 +++------ .../web/class_WebShipsimuUserLoginCommand.php | 38 +++++++++---------- 5 files changed, 55 insertions(+), 64 deletions(-) diff --git a/application/ship-simu/exceptions.php b/application/ship-simu/exceptions.php index 98989ee..6d606d9 100644 --- a/application/ship-simu/exceptions.php +++ b/application/ship-simu/exceptions.php @@ -25,10 +25,11 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s: %s. Backtrace:
%s
", + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s[%s]: %s. Backtrace:
%s
", ApplicationHelper::getInstance()->getAppName(), ApplicationHelper::getInstance()->getAppShortName(), $e->__toString(), + $e->getHexCode(), $e->getMessage(), $e->getPrintableBackTrace() )); diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php index 60d7fa9..0c9e6cb 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php @@ -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')); } } diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php index 18adfa0..3fa1529 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php @@ -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')); } } diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php index 3958ea5..61c537a 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php @@ -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')); } } diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php index 908d1f1..3721c08 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php @@ -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')); } } -- 2.39.5