Debug mailer finished and debug messages removed:
[shipsimu.git] / inc / classes / main / commands / web / class_WebResendLinkCommand.php
index 9ff8050..fda4669 100644 (file)
@@ -76,18 +76,9 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
                        throw new InvalidInterfaceException(array($userInstance, 'ManageableUser'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
                } // END - if
 
-               // Get template instance
-               $templateInstance = $responseInstance->getTemplateInstance();
-
                // Get an application instance
                $appInstance = $this->getResolverInstance()->getApplicationInstance();
 
-               // Assign the application data with the template engine
-               $templateInstance->assignApplicationData($appInstance);
-
-               // Assign base URL
-               $templateInstance->assignConfigVariable('base_url');
-
                // Get a RNG instance (Random Number Generator)
                $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
 
@@ -101,19 +92,34 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
                $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
 
                // Update the user class
-               $userInstance->updateDatabaseField('confirm_hash', $hashedString);
+               $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString);
+
+               // Re-set config entry to mailer engine
+               $this->getConfigInstance()->setConfigEntry('template_class', $this->getConfigInstance()->readConfig('mail_template_class'));
 
-               // Assign the hash with a template variable
-               $templateInstance->assignVariable('confirm_hash', $hashedString);
+               // Prepare the template engine
+               $templateInstance = $this->prepareTemplateInstance($appInstance);
+
+               // Assign the application data with the template engine
+               $templateInstance->assignApplicationData($appInstance);
 
                // Get a mailer class
-               $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance));
+               $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $appInstance, 'resend_link'));
 
-               // Load the mail template
-               $mailerInstance->loadTemplate('resend_link');
+               // Set this mailer in our template engine
+               $templateInstance->setMailerInstance($mailerInstance);
 
-               // Get a user instance from registry
-               $userInstance = Registry::getRegistry()->getInstance('user');
+               // Add template variables we shall get
+               $mailerInstance->addConfigTemplateVariable('base_url');
+               $mailerInstance->addConfigTemplateVariable('admin_email');
+               $mailerInstance->addValueTemplateVariable('confirm_hash');
+               $mailerInstance->addValueTemplateVariable('username');
+               $mailerInstance->addValueTemplateVariable('email');
+
+               // Add the value instance for the confirmation hash
+               $mailerInstance->addValueInstance('confirm_hash', $userInstance);
+               $mailerInstance->addValueInstance('username', $userInstance);
+               $mailerInstance->addValueInstance('email', $userInstance);
 
                // Add the recipient
                $mailerInstance->addRecipientByUserInstance($userInstance);
@@ -122,10 +128,10 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
                $mailerInstance->useSubjectFromTemplate();
 
                // Send the email out
-               $mailerInstance->deliverEmail();
+               $mailerInstance->deliverEmail($responseInstance);
 
                // Send out notification to admin (depends on settings)
-               $mailerInstance->sendAdminNotification();
+               $mailerInstance->sendAdminNotification($responseInstance);
        }
 
        /**