Continued:
[core.git] / framework / main / classes / mailer / debug / class_DebugMailer.php
index 876f32306e94134b0b65f5ee93f739bc861d2b9d..884b385877b1fe035a661b291bd9d79a6534c5b8 100644 (file)
@@ -5,19 +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\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
- * @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
  *
@@ -40,7 +44,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -53,7 +57,7 @@ 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, $templateName) {
+       public static final function createDebugMailer (CompileableTemplate $templateInstance, string $templateName) {
                // Get a new instance
                $mailerInstance = new DebugMailer();
 
@@ -71,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
@@ -84,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);
@@ -97,15 +101,15 @@ 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) {
                                        // Is the value instance there?
                                        if (!isset($recipientList['values'][$variable])) {
                                                // Throw exception
-                                               throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-                                       } // END - if
+                                               throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
+                                       }
 
                                        // Get the field from the value instance
                                        $fieldValue = $recipientList['values'][$variable]->getField($variable);
@@ -122,8 +126,8 @@ class DebugMailer extends BaseMailer implements DeliverableMail {
 
                                // Transfer the data to the response
                                $templateInstance->transferToResponse($responseInstance);
-                       } // END - foreach
-               } // END - foreach
+                       }
+               }
        }
 
        /**
@@ -173,7 +177,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail {
                $templateInstance->assignTemplateWithVariable('footer', 'footer');
 
                // Get master template name
-               $masterTemplateName = GenericRegistry::getRegistry()->getInstance('application')->buildMasterTemplateName();
+               $masterTemplateName = ApplicationHelper::getSelfInstance()->buildMasterTemplateName();
 
                // Load the master template
                $templateInstance->loadCodeTemplate($masterTemplateName);