// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Mailer\BaseMailer;
use Org\Mxchange\CoreFramework\Mailer\DeliverableMail;
use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember;
-use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
-use Org\Mxchange\CoreFramework\Registry\Registry;
+use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+// Import SPL stuff
+use \UnexpectedValueException;
+
/**
* A mailer class for debugging purposes only. This class will print the
* prepared mail out and will not send it to the recipient.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
-<<<<<<< HEAD:framework/main/classes/mailer/debug/class_DebugMailer.php
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
-=======
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
->>>>>>> Some updates::inc/main/classes/mailer/debug/class_DebugMailer.php
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @return void
*/
- protected function __construct () {
+ private function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
}
* @param $templateName Name of email template to set
* @return $mailerInstance An instance of this mailer class
*/
- public static final function createDebugMailer (CompileableTemplate $templateInstance, ManageableApplication $applicationInstance, $templateName) {
+ public static final function createDebugMailer (CompileableTemplate $templateInstance, string $templateName) {
// Get a new instance
$mailerInstance = new DebugMailer();
// Set template instance
$mailerInstance->setTemplateInstance($templateInstance);
- // Set application instance
- $mailerInstance->setApplicationInstance($applicationInstance);
-
// Set template name
$mailerInstance->setTemplateName($templateName);
* Deliver email to the recipient(s)
*
* @return void
- * @throws InvalidInterfaceException If the recipient instance does not implement ManageableMember
+ * @throws UnexpectedValueException If the recipient instance does not implement ManageableMember
*/
public function deliverEmail () {
// Get template instance
// The recipient should be a user instance, right?
if (!$recipientInstance instanceof ManageableMember) {
// Invalid entry found!
- throw new InvalidInterfaceException(array($this, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
- } // END - if
+ throw new UnexpectedValueException(sprintf('recipientInstance[]=%s does not implement ManageableMember', gettype($recipientInstance)));
+ }
// User class found, so entry is valid, first load the template
$this->loadTemplate($templateName);
foreach ($recipientList['config_vars'] as $variable => $dummy) {
// Load the config value and set it
$templateInstance->assignConfigVariable($variable);
- } // END - if
+ }
// Now do the same with the values but ask the "value instance" instead!
foreach ($recipientList['value_vars'] as $variable => $dummy) {
if (!isset($recipientList['values'][$variable])) {
// Throw exception
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
+ }
// Get the field from the value instance
$fieldValue = $recipientList['values'][$variable]->getField($variable);
// Transfer the data to the response
$templateInstance->transferToResponse($responseInstance);
- } // END - foreach
- } // END - foreach
+ }
+ }
}
/**
$templateInstance->compileTemplate();
$templateInstance->assignTemplateWithVariable('footer', 'footer');
+ // Get master template name
+ $masterTemplateName = ApplicationHelper::getSelfInstance()->buildMasterTemplateName();
+
// Load the master template
- $templateInstance->loadCodeTemplate(Registry::getRegistry()->getInstance('app')->buildMasterTemplateName());
+ $templateInstance->loadCodeTemplate($masterTemplateName);
// Then compile it again
$templateInstance->compileVariables();