class_WebResendLinkCommand.php
Go to the documentation of this file.00001 <?php
00024 class WebResendLinkCommand extends BaseCommand implements Commandable {
00030 protected function __construct () {
00031
00032 parent::__construct(__CLASS__);
00033 }
00034
00041 public final static function createWebResendLinkCommand (CommandResolver $resolverInstance) {
00042
00043 $commandInstance = new WebResendLinkCommand();
00044
00045
00046 $commandInstance->setResolverInstance($resolverInstance);
00047
00048
00049 return $commandInstance;
00050 }
00051
00060 public function execute (Requestable $requestInstance, Responseable $responseInstance) {
00061
00062 $userInstance = Registry::getRegistry()->getInstance('user');
00063
00064
00065 if (!$userInstance instanceof ManageableMember) {
00066
00067 throw new InvalidInterfaceException(array($userInstance, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
00068 }
00069
00070
00071 $appInstance = $this->getResolverInstance()->getApplicationInstance();
00072
00073
00074 $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
00075
00076
00077 $randomString = $rngInstance->randomString(255);
00078
00079
00080 $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
00081
00082
00083 $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
00084
00085
00086 $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString);
00087
00088
00089 $this->getConfigInstance()->setConfigEntry('template_class', $this->getConfigInstance()->readConfig('mail_template_class'));
00090
00091
00092 $templateInstance = $this->prepareTemplateInstance($appInstance);
00093
00094
00095 $templateInstance->assignApplicationData($appInstance);
00096
00097
00098 $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $appInstance, 'resend_link'));
00099
00100
00101 $templateInstance->setMailerInstance($mailerInstance);
00102
00103
00104 $mailerInstance->addConfigTemplateVariable('base_url');
00105 $mailerInstance->addConfigTemplateVariable('admin_email');
00106 $mailerInstance->addValueTemplateVariable('confirm_hash');
00107 $mailerInstance->addValueTemplateVariable('username');
00108 $mailerInstance->addValueTemplateVariable('email');
00109
00110
00111 $mailerInstance->addValueInstance('confirm_hash', $userInstance);
00112 $mailerInstance->addValueInstance('username', $userInstance);
00113 $mailerInstance->addValueInstance('email', $userInstance);
00114
00115
00116 $mailerInstance->addRecipientByUserInstance($userInstance);
00117
00118
00119 $mailerInstance->useSubjectFromTemplate();
00120
00121
00122 $mailerInstance->deliverEmail($responseInstance);
00123
00124
00125 $mailerInstance->sendAdminNotification($responseInstance);
00126 }
00127
00135 public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
00136
00137 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
00138 }
00139 }
00140
00141
00142 ?>