<?php
// Own namespace
-namespace CoreFramework\Template\Engine;
+namespace Org\Mxchange\CoreFramework\Template\Engine;
// Import framework stuff
-use CoreFramework\Filesystem\InvalidDirectoryException;
-use CoreFramework\Mailer\DeliverableMail;
-use CoreFramework\Parser\Xml\XmlParser;
-use CoreFramework\Registry\Registry;
-use CoreFramework\Response\Responseable;
-use CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Mailer\DeliverableMail;
+use Org\Mxchange\CoreFramework\Parser\Parseable;
+use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
+use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
// Import SPL stuff
use \UnexpectedValueException;
*
* @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 - 2020 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
/**
* Main nodes in the XML tree
*/
- private $mainNodes = array(
+ private $mainNodes = [
'mail-data'
- );
+ ];
/**
* Sub nodes in the XML tree
*/
- private $subNodes = array(
+ private $subNodes = [
'subject-line',
'sender-address',
'recipient-address',
'message'
- );
+ ];
/**
* Mailer instance
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Set template type
+ $this->setTemplateType('mail');
}
/**
$templateInstance = new MailTemplateEngine();
// Get the application instance from registry
- $applicationInstance = Registry::getRegistry()->getInstance('app');
+ $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
// Determine base path
- $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
+ $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
// Is the base path valid?
if (empty($templateBasePath)) {
$templateInstance->setTemplateBasePath($templateBasePath);
// Set template extensions
- $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
- $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
+ $templateInstance->setRawTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('raw_template_extension'));
+ $templateInstance->setCodeTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('code_template_extension'));
// Absolute output path for compiled templates
$templateInstance->setCompileOutputPath(sprintf('%s%s/',
$templateBasePath,
- $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')
+ FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('compile_output_path')
));
// Return the prepared instance
* @return void
* @throws InvalidXmlNodeException If an unknown/invalid XML node name was found
*/
- public function startElement ($resource, $element, array $attributes) {
+ public function startElement ($resource, string $element, array $attributes) {
// Initial method name which will never be called...
$methodName = 'initEmail';
//* DEBUG: */ echo "START: >".$element."<<br />\n";
if (in_array($element, $this->getMainNodes())) {
// Okay, main node found!
- $methodName = 'setEmail' . self::convertToClassName($element);
+ $methodName = 'setEmail' . StringUtils::convertToClassName($element);
} elseif (in_array($element, $this->getSubNodes())) {
// Sub node found
- $methodName = 'setEmailProperty' . self::convertToClassName($element);
+ $methodName = 'setEmailProperty' . StringUtils::convertToClassName($element);
} elseif ($element != 'text-mail') {
// Invalid node name found
- throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
+ throw new InvalidXmlNodeException(array($this, $element, $attributes), Parseable::EXCEPTION_XML_NODE_UNKNOWN);
}
// Call method
* @return void
* @throws XmlNodeMismatchException If current main node mismatches the closing one
*/
- public function finishElement ($resource, $nodeName) {
- // Make all lower-case
- $nodeName = strtolower($nodeName);
-
+ public function finishElement ($resource, string $nodeName) {
// Does this match with current main node?
//* DEBUG: */ echo "END: >".$nodeName."<<br />\n";
if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
// Did not match!
- throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
+ throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), Parseable::EXCEPTION_XML_NODE_MISMATCH);
} elseif (in_array($nodeName, $this->getSubNodes())) {
// Silently ignore sub nodes
return;
}
// Construct method name
- $methodName = 'finish' . self::convertToClassName($nodeName);
+ $methodName = 'finish' . StringUtils::convertToClassName($nodeName);
// Call the corresponding method
- call_user_func_array(array($this, $methodName), array());
+ call_user_func_array(array($this, $methodName), []);
}
/**
* @param $characters Characters to handle
* @return void
*/
- public function characterHandler ($resource, $characters) {
+ public function characterHandler ($resource, string $characters) {
// Trim all spaces away
$characters = trim($characters);
$this->getMailerInstance()->invokeMailDelivery();
}
- /**
- * Getter for image cache file (FQFN)
- *
- * @return $fqfn Full-qualified file name of the image cache
- * @todo 0% done
- */
- public function getMailCacheFqfn () {
- // Initialize FQFN
- $fqfn = '';
- $this->debugBackTrace('Unfinished area!');
-
- // Return it
- return $fqfn;
- }
-
/**
* Setter for mailer instance
*