]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php
Class/method doc-tags fixed
[shipsimu.git] / application / ship-simu / main / commands / web / class_WebShipsimuRegisterCommand.php
index a419393fb379cc4b97305fd579662c0bb39b63c7..b7c240f9719673f8991478d86633800b941223c2 100644 (file)
@@ -35,7 +35,7 @@ class WebShipsimuRegisterCommand extends BaseCommand implements Commandable {
                $this->setObjectDescription("Registration handling command for Ship-Simu");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeNumberFormaters();
@@ -55,13 +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('username_validator'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator'));
-
                // Return the prepared instance
                return $commandInstance;
        }
@@ -74,7 +67,44 @@ class WebShipsimuRegisterCommand extends BaseCommand implements Commandable {
         * @return      void
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               $this->partialStub();
+               // First get a UserRegistration instance
+               $registerInstance = ObjectFactory::createObjectByConfiguredName('user_registration_class');
+
+               // First set request and response instance
+               $registerInstance->setRequestInstance($requestInstance);
+               $registerInstance->setResponseInstance($responseInstance);
+
+               // Encrypt the password
+               $registerInstance->encryptPassword('pass1');
+
+               // Do things before registration
+               $registerInstance->doPreRegistration();
+
+               // Register the new user
+               $registerInstance->registerNewUser();
+
+               // Do things after registration like notifying partner pages or queueing
+               // them for notification
+               $registerInstance->doPostRegistration();
+
+               // Redirect or login after registration
+               $registerInstance->doPostAction();
+       }
+
+       /**
+        * 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 more pre/post filters to the controller
+        */
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+               $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'));
        }
 }