Rewritten:
[core.git] / framework / main / classes / template / class_BaseTemplateEngine.php
index a233e776e1e2386812a0efc8bf2d2f30b5e91968..5ca3c6ad2b7f38a3b2b90c7f5f94483ce79d120e 100644 (file)
@@ -12,6 +12,9 @@ use CoreFramework\Manager\ManageableApplication;
 use CoreFramework\Object\BaseFrameworkSystem;
 use CoreFramework\Response\Responseable;
 
 use CoreFramework\Object\BaseFrameworkSystem;
 use CoreFramework\Response\Responseable;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A generic template engine
  *
 /**
  * A generic template engine
  *
@@ -78,9 +81,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        private $compiledData = '';
 
        /**
        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
 
        /**
         * The variable stack for the templates
@@ -494,17 +497,17 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        }
 
        /**
        }
 
        /**
-        * 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
         */
         *
         * @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
         */
         *
         * @return      $template       The last loaded template
         */
@@ -692,19 +695,19 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                 * now entirely done by php_intl. These old thing with language-based
                 * template paths comes from an older time.
                 */
                 * 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',
+               $fileInstance = new SplFileInfo(sprintf('%s%s%s%s%s%s',
                        $this->getTemplateBasePath(),
                        $this->getGenericBasePath(),
                        $this->getTemplateType(),
                        DIRECTORY_SEPARATOR,
                        (string) $templateName,
                        $ext
                        $this->getTemplateBasePath(),
                        $this->getGenericBasePath(),
                        $this->getTemplateType(),
                        DIRECTORY_SEPARATOR,
                        (string) $templateName,
                        $ext
-               );
+               ));
 
                // First try this
                try {
                        // Load the raw template data
 
                // 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))) {
                } 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))) {
@@ -715,7 +718,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                $this->loadTemplate($templateName, $ext);
                        } else {
                                // Throw it again
                                $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);
                        }
                }
 
                        }
                }
 
@@ -724,21 +727,21 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        /**
         * A private loader for raw template names
         *
        /**
         * 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
         */
         * @return      void
         */
-       private function loadRawTemplateData ($fqfn) {
+       private function loadRawTemplateData (SplFileInfo $fileInstance) {
                // Some debug code to look on the file which is being loaded
                // 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
 
                // 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);
 
 
                // 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);
        }
 
        /**
        }
 
        /**