Continued:
[core.git] / framework / main / classes / mailer / class_BaseMailer.php
index 6c0a52aa67820fe4d41d8c29a59f28a743b9e9f3..dd95136132f1b4d3064a09977c57929cc0a57c81 100644 (file)
@@ -3,16 +3,18 @@
 namespace Org\Mxchange\CoreFramework\Mailer;
 
 // Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general mailer class for all other mailers
  *
  * @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
  *
@@ -30,6 +32,9 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseMailer extends BaseFrameworkSystem {
+       // Load traits
+       use CompileableTemplateTrait;
+
        /**
         * Template name
         */
@@ -41,7 +46,7 @@ abstract class BaseMailer extends BaseFrameworkSystem {
         * @param       $className      Name of the class
         * @return      void
         */
-       protected function __construct ($className) {
+       protected function __construct (string $className) {
                // Call parent constructor
                parent::__construct($className);
        }
@@ -52,12 +57,12 @@ abstract class BaseMailer extends BaseFrameworkSystem {
         * @param       $templateName   Name of the template we shall load
         * @return      void
         */
-       protected final function loadTemplate ($templateName) {
+       protected final function loadTemplate (string $templateName) {
                // Set template name
                $this->setTemplateName($templateName);
 
                // Get configuration entry
-               $templatePrefix = $this->getConfigInstance()->getConfigEntry('email_tpl_' . $templateName);
+               $templatePrefix = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('email_tpl_' . $templateName);
 
                // Load this email template
                $this->getTemplateInstance()->loadEmailTemplate($templatePrefix . '_' . $templateName);
@@ -122,7 +127,7 @@ abstract class BaseMailer extends BaseFrameworkSystem {
         * @param       $valueInstance  An object instance which can provide "field values"
         * @return      void
         */
-       public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) {
+       public final function addValueInstance (string $variableName, FrameworkInterface $valueInstance) {
                $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'values', $variableName, $valueInstance);
        }
 
@@ -132,8 +137,8 @@ abstract class BaseMailer extends BaseFrameworkSystem {
         * @param       $templateName   Name of email template
         * @return      void
         */
-       public final function setTemplateName ($templateName) {
-               $this->templateName = (string) $templateName;
+       public final function setTemplateName (string $templateName) {
+               $this->templateName = $templateName;
        }
 
        /**
@@ -151,7 +156,7 @@ abstract class BaseMailer extends BaseFrameworkSystem {
         * @param       $subjectLine    Subject line to set
         * @return      void
         */
-       public final function setSubjectLine ($subjectLine) {
+       public final function setSubjectLine (string $subjectLine) {
                $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'generic', 'subject', $subjectLine);
        }
 
@@ -171,7 +176,7 @@ abstract class BaseMailer extends BaseFrameworkSystem {
                if ((!empty($templateName)) && ($this->isGenericArrayElementSet('recipients', $templateName, 'generic', 'subject'))) {
                        // Then use it
                        $subjectLine = $this->getGenericArrayElement('recipients', $templateName, 'generic', 'subject');
-               } // END - if
+               }
 
                // Return it
                return $subjectLine;