protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
-
- // Set part description
- $this->setObjectDescription("A mailer for debugging purposes");
-
- // Create unique ID number
- $this->generateUniqueId();
}
/**
* Deliver email to the recipient(s)
*
* @return void
+ * @throws InvalidInterfaceException If the recipient instance does not implement ManageableMember
*/
public function deliverEmail () {
// Get template instance
// Walk through all recipients and "sent", or better print, it out
foreach ($recipientList['recipients'] as $recipientInstance) {
// The recipient should be a user instance, right?
- if ($recipientInstance instanceof ManageableMember) {
- // User class found, so entry is valid, first load the template
- $this->loadTemplate($templateName);
+ if (!$recipientInstance instanceof ManageableMember) {
+ // Invalid entry found!
+ throw new InvalidInterfaceException(array($this, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
+ }
- // Set subject line
- $templateInstance->assignVariable('subject', $this->getSubjectLine());
+ // User class found, so entry is valid, first load the template
+ $this->loadTemplate($templateName);
- // Walk through all variables, first config to assign them
- foreach ($recipientList['config_vars'] as $variable=>$dummy) {
- // Load the config value and set it
- $templateInstance->assignConfigVariable($variable);
- } // END - if
+ // Set subject line
+ $templateInstance->assignVariable('subject', $this->getSubjectLine());
- // Now do the same with the values but ask the "value instance" instead!
- foreach ($recipientList['value_vars'] as $variable=>$dummy) {
- // Is the value instance there?
- if (!isset($recipientList['values'][$variable])) {
- // Throw exception
- throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
+ // Walk through all variables, first config to assign them
+ foreach ($recipientList['config_vars'] as $variable => $dummy) {
+ // Load the config value and set it
+ $templateInstance->assignConfigVariable($variable);
+ } // END - if
- // Get the field from the value instance
- $fieldValue = $recipientList['values'][$variable]->getField($variable);
+ // Now do the same with the values but ask the "value instance" instead!
+ foreach ($recipientList['value_vars'] as $variable => $dummy) {
+ // Is the value instance there?
+ if (!isset($recipientList['values'][$variable])) {
+ // Throw exception
+ throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
- // Set it in the template engine
- $templateInstance->assignVariable($variable, $fieldValue);
- }
+ // Get the field from the value instance
+ $fieldValue = $recipientList['values'][$variable]->getField($variable);
- // Render the content
- $templateInstance->renderXmlContent();
+ // Set it in template engine
+ $templateInstance->assignVariable($variable, $fieldValue);
+ }
- // Get responce instance
- $responseInstance = $this->getApplicationInstance()->getResponseInstance();
+ // Render the content
+ $templateInstance->renderXmlContent();
- // Transfer the data to the response
- $this->getTemplateInstance()->transferToResponse($responseInstance);
- } else {
- // Invalid entry found!
- $this->partialStub("Handling of invalid recipient entries not yet finished.");
- }
+ // Get responce instance
+ $responseInstance = $this->getApplicationInstance()->getResponseInstance();
+
+ // Transfer the data to the response
+ $this->getTemplateInstance()->transferToResponse($responseInstance);
} // END - foreach
} // END - foreach
}