00001 <?php 00024 class WebShipsimuGuestLoginCommand extends BaseCommand implements Commandable { 00030 protected function __construct () { 00031 // Call parent constructor 00032 parent::__construct(__CLASS__); 00033 00034 // Clean up a little 00035 $this->removeNumberFormaters(); 00036 $this->removeSystemArray(); 00037 } 00038 00045 public final static function createWebShipsimuGuestLoginCommand (CommandResolver $resolverInstance) { 00046 // Get a new instance 00047 $commandInstance = new WebShipsimuGuestLoginCommand(); 00048 00049 // Set the resolver instance 00050 $commandInstance->setResolverInstance($resolverInstance); 00051 00052 // Return the prepared instance 00053 return $commandInstance; 00054 } 00055 00063 public function execute (Requestable $requestInstance, Responseable $responseInstance) { 00064 // First get a GuestLogin instance 00065 $loginInstance = ObjectFactory::createObjectByConfiguredName('guest_login_class'); 00066 00067 // First set request and response instance 00068 $loginInstance->setRequestInstance($requestInstance); 00069 00070 // Encrypt the password 00071 $loginInstance->encryptPassword('passwd'); 00072 00073 // Do the login here 00074 $loginInstance->doLogin($requestInstance, $responseInstance); 00075 00076 // Was the login fine? Then redirect here 00077 if ($loginInstance->ifLoginWasSuccessfull()) { 00078 // Try to redirect here 00079 try { 00080 // Redirect... 00081 $responseInstance->redirectToConfiguredUrl('app_login_url'); 00082 00083 // Exit here 00084 exit(); 00085 } catch (FrameworkException $e) { 00086 // Something went wrong here! 00087 $responseInstance->addFatalMessage($e->getMessage()); 00088 } 00089 } else { 00090 // Attach error message to the response 00091 $responseInstance->addFatalMessage('failed_user_login'); 00092 } 00093 } 00094 00103 public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { 00104 // Add username verifier filter 00105 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_guest_verifier_filter')); 00106 00107 // Add password verifier filter 00108 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('passwd_guest_verifier_filter')); 00109 00110 // Add CAPTCHA verifier code 00111 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_guest_verifier_filter')); 00112 } 00113 } 00114 00115 // [EOF] 00116 ?>
1.5.6