X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fmailer%2Fdebug%2Fclass_DebugMailer.php;h=3d34d0453217716d0b34adc218a1e0c6a3d17aea;hb=c21969ecc9ea3689d37dac8dd39ea202b2726e99;hp=372aed8e067b9e316aaa008003b5be2a079d013a;hpb=b002c5909aa0f781505dde5414964b0f014cde01;p=core.git diff --git a/framework/main/classes/mailer/debug/class_DebugMailer.php b/framework/main/classes/mailer/debug/class_DebugMailer.php index 372aed8e..3d34d045 100644 --- a/framework/main/classes/mailer/debug/class_DebugMailer.php +++ b/framework/main/classes/mailer/debug/class_DebugMailer.php @@ -5,20 +5,23 @@ namespace Org\Mxchange\CoreFramework\Mailer\Debug; // 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\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 * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -41,7 +44,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * * @return void */ - protected function __construct () { + private function __construct () { // Call parent constructor parent::__construct(__CLASS__); } @@ -54,16 +57,13 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * @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); @@ -75,7 +75,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { * 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 @@ -88,8 +88,8 @@ class DebugMailer extends BaseMailer implements DeliverableMail { // 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)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE); + } // User class found, so entry is valid, first load the template $this->loadTemplate($templateName); @@ -101,7 +101,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { 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) { @@ -109,7 +109,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { 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); @@ -126,8 +126,8 @@ class DebugMailer extends BaseMailer implements DeliverableMail { // Transfer the data to the response $templateInstance->transferToResponse($responseInstance); - } // END - foreach - } // END - foreach + } + } } /** @@ -176,8 +176,11 @@ class DebugMailer extends BaseMailer implements DeliverableMail { $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();