class_DebugMailer.php

Go to the documentation of this file.
00001 <?php
00025 class DebugMailer extends BaseMailer implements DeliverableMail {
00031         protected function __construct () {
00032                 // Call parent constructor
00033                 parent::__construct(__CLASS__);
00034         }
00035 
00044         public final static function createDebugMailer (CompileableTemplate $templateInstance, ManageableApplication $appInstance, $templateName) {
00045                 // Get a new instance
00046                 $mailerInstance = new DebugMailer();
00047 
00048                 // Set template instance
00049                 $mailerInstance->setTemplateInstance($templateInstance);
00050 
00051                 // Set application instance
00052                 $mailerInstance->setApplicationInstance($appInstance);
00053 
00054                 // Set template name
00055                 $mailerInstance->setTemplateName('resend_link');
00056 
00057                 // Return the instance
00058                 return $mailerInstance;
00059         }
00060 
00067         public function deliverEmail () {
00068                 // Get template instance
00069                 $templateInstance = $this->getTemplateInstance();
00070 
00071                 // "Deliver" all emails
00072                 foreach ($this->getRecipientList() as $templateName => $recipientList) {
00073                         // Walk through all recipients and "sent", or better print, it out
00074                         foreach ($recipientList['recipients'] as $recipientInstance) {
00075                                 // The recipient should be a user instance, right?
00076                                 if (!$recipientInstance instanceof ManageableMember) {
00077                                         // Invalid entry found!
00078                                         throw new InvalidInterfaceException(array($this, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
00079                                 }
00080 
00081                                 // User class found, so entry is valid, first load the template
00082                                 $this->loadTemplate($templateName);
00083 
00084                                 // Set subject line
00085                                 $templateInstance->assignVariable('subject', $this->getSubjectLine());
00086 
00087                                 // Walk through all variables, first config to assign them
00088                                 foreach ($recipientList['config_vars'] as $variable => $dummy) {
00089                                         // Load the config value and set it
00090                                         $templateInstance->assignConfigVariable($variable);
00091                                 } // END - if
00092 
00093                                 // Now do the same with the values but ask the "value instance" instead!
00094                                 foreach ($recipientList['value_vars'] as $variable => $dummy) {
00095                                         // Is the value instance there?
00096                                         if (!isset($recipientList['values'][$variable])) {
00097                                                 // Throw exception
00098                                                 throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
00099                                         } // END - if
00100 
00101                                         // Get the field from the value instance
00102                                         $fieldValue = $recipientList['values'][$variable]->getField($variable);
00103 
00104                                         // Set it in template engine
00105                                         $templateInstance->assignVariable($variable, $fieldValue);
00106                                 }
00107 
00108                                 // Render the content
00109                                 $templateInstance->renderXmlContent();
00110 
00111                                 // Get responce instance
00112                                 $responseInstance = $this->getApplicationInstance()->getResponseInstance();
00113 
00114                                 // Transfer the data to the response
00115                                 $this->getTemplateInstance()->transferToResponse($responseInstance);
00116                         } // END - foreach
00117                 } // END - foreach
00118         }
00119 
00126         public function sendAdminNotification () {
00127                 // Unfinished work
00128         }
00129 
00135         public function invokeMailDelivery () {
00136                 // Get template instance
00137                 $templateInstance = $this->getTemplateInstance();
00138 
00139                 // Get the compiled message and set it as new template variable
00140                 $message = $templateInstance->getCompiledData();
00141                 $templateInstance->assignVariable('message', $message);
00142 
00143                 // Load the code template
00144                 $templateInstance->loadCodeTemplate('mail_debug');
00145 
00146                 // Compile the template
00147                 $templateInstance->compileTemplate();
00148 
00149                 // Assign this template with variable
00150                 $templateInstance->assignTemplateWithVariable('mail_debug', 'content');
00151 
00152                 // Load header template
00153                 $templateInstance->loadCodeTemplate('header');
00154 
00155                 // Compile and assign it with a variable
00156                 $templateInstance->compileTemplate();
00157                 $templateInstance->assignTemplateWithVariable('header', 'header');
00158 
00159                 // Load footer template
00160                 $templateInstance->loadCodeTemplate('footer');
00161 
00162                 // Compile and assign it with a variable
00163                 $templateInstance->compileTemplate();
00164                 $templateInstance->assignTemplateWithVariable('footer', 'footer');
00165 
00166                 // Load the master template
00167                 $templateInstance->loadCodeTemplate($this->getApplicationInstance()->getMasterTemplate());
00168 
00169                 // Then compile it again
00170                 $templateInstance->compileVariables();
00171         }
00172 }
00173 
00174 // [EOF]
00175 ?>

Generated on Mon Dec 8 01:06:46 2008 for Ship-Simulator by  doxygen 1.5.6