<?php
// Own namespace
-namespace CoreFramework\Template\Engine;
+namespace Org\Mxchange\CoreFramework\Template\Engine;
// Import framework stuff
-use CoreFramework\Bootstrap\FrameworkBootstrap;
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Generic\EmptyVariableException;
-use CoreFramework\Manager\ManageableApplication;
-use CoreFramework\Object\BaseFrameworkSystem;
-use CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
+use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+use \SplFileInfo;
/**
* A generic template engine
private $compiledData = '';
/**
- * The last loaded template's FQFN for debugging the engine
+ * The last loaded template's file instance (SplFileInfo)
*/
- private $lastTemplate = '';
+ private $lastTemplate = NULL;
/**
* The variable stack for the templates
}
/**
- * Setter for the last loaded template's FQFN
+ * Setter for the last loaded template's file instance
*
* @param $template The last loaded template
* @return void
*/
- private final function setLastTemplate ($template) {
- $this->lastTemplate = (string) $template;
+ private final function setLastTemplate (SplFileInfo $fileInstance) {
+ $this->lastTemplate = $fileInstance;
}
/**
- * Getter for the last loaded template's FQFN
+ * Getter for the last loaded template's file instance
*
* @return $template The last loaded template
*/
/**
* Private loader for all template types
*
- * @param $template The template we shall load
+ * @param $templateName The template we shall load
* @param $extOther An other extension to use
* @return void
* @throws FileNotFoundException If the template was not found
*/
- protected function loadTemplate ($template, $extOther = '') {
+ protected function loadTemplate ($templateName, $extOther = '') {
// Get extension for the template if empty
if (empty($extOther)) {
// None provided, so get the raw one
* now entirely done by php_intl. These old thing with language-based
* template paths comes from an older time.
*/
- $fqfn = sprintf('%s%s%s%s/%s%s',
- $this->getConfigInstance()->getConfigEntry('application_base_path'),
+ $fileInstance = new SplFileInfo(sprintf('%s%s%s%s%s%s',
$this->getTemplateBasePath(),
$this->getGenericBasePath(),
$this->getTemplateType(),
- (string) $template,
+ DIRECTORY_SEPARATOR,
+ (string) $templateName,
$ext
- );
+ ));
// First try this
try {
// Load the raw template data
- $this->loadRawTemplateData($fqfn);
+ $this->loadRawTemplateData($fileInstance);
} catch (FileNotFoundException $e) {
// If we shall load a code-template we need to switch the file extension
if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('html_template_type')) && (empty($extOther))) {
$ext = $this->getCodeTemplateExtension();
// Try it again...
- $this->loadTemplate($template, $ext);
+ $this->loadTemplate($templateName, $ext);
} else {
// Throw it again
- throw new FileNotFoundException($fqfn, self::EXCEPTION_FILE_NOT_FOUND);
+ throw new FileNotFoundException($fileInstance, self::EXCEPTION_FILE_NOT_FOUND);
}
}
/**
* A private loader for raw template names
*
- * @param $fqfn The full-qualified file name for a template
+ * @param $fileInstance An instance of a SplFileInfo class
* @return void
*/
- private function loadRawTemplateData ($fqfn) {
+ private function loadRawTemplateData (SplFileInfo $fileInstance) {
// Some debug code to look on the file which is being loaded
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: FQFN=' . $fqfn);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: fileInstance=' . $fileInstance);
// Load the raw template
- $rawTemplateData = $this->getFileIoInstance()->loadFileContents($fqfn);
+ $rawTemplateData = $this->getFileIoInstance()->loadFileContents($fileInstance);
// Store the template's contents into this class
$this->setRawTemplateData($rawTemplateData);
- // Remember the template's FQFN
- $this->setLastTemplate($fqfn);
+ // Remember the template's file instance
+ $this->setLastTemplate($fileInstance);
}
/**
$this->assignVariable($var, $varMatches[3][$key]);
} elseif (!empty($varMatches[2][$key])) {
// @TODO Non-string found so we need some deeper analysis...
- ApplicationEntryPoint::app_exit('Deeper analysis not yet implemented!');
+ ApplicationEntryPoint::exitApplication('Deeper analysis not yet implemented!');
}
} // END - foreach
}
* @param $variableName The variable we are looking for
* @param $value The value we want to store in the variable
* @return void
- * @throws EmptyVariableException If the variable name is left empty
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public final function assignVariable ($variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
// Empty variable found?
if (empty($variableName)) {
// Throw an exception
- throw new EmptyVariableException(array($this, 'variableName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new InvalidArgumentException('Parameter "variableName" is empty');
} // END - if
// First search for the variable if it was already added