]> git.mxchange.org Git - shipsimu.git/commitdiff
Template engine now checks variables first then code template
authorRoland Häder <roland@mxchange.org>
Tue, 27 May 2008 19:03:35 +0000 (19:03 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 27 May 2008 19:03:35 +0000 (19:03 +0000)
inc/classes/main/controller/form/class_WebDoFormController.php
inc/classes/main/template/class_TemplateEngine.php
index.php

index 7e2e086214a9b2bef608762b2b85019153eb2712..6c01d87a18b474462df565cb4effc9f49b0d7ca0 100644 (file)
@@ -51,6 +51,9 @@ class WebDoFormController extends BaseController implements Controller {
                // Set resolver instance
                $controllerInstance->setResolverInstance($resolverInstance);
 
+               // Generate some pre/post filters
+               $controllerInstance->addDoFormPrePostFilters();
+
                // Return the prepared instance
                return $controllerInstance;
        }
@@ -65,6 +68,7 @@ class WebDoFormController extends BaseController implements Controller {
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
                // Run all pre filters
                $this->executePreFilters($requestInstance, $responseInstance);
+               $requestInstance->debugInstance();
 
                // Get command instance from resolver
                $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
@@ -78,6 +82,17 @@ class WebDoFormController extends BaseController implements Controller {
                // Do something more here
                die("OK");
        }
+
+       /**
+        * Add some default pre/post filters for this controller to the matching
+        * filter chains
+        *
+        * @return      void
+        */
+       protected function addDoFormPrePostFilters () {
+               // Add a filter to check for missing user name
+               $this->addPreFilter(UserNameValidatorFilter::createUserNameValidatorFilter());
+       }
 }
 
 // [EOF]
index ee01937a364d75ebae00264c73138131e83a4b19..64902cbd2c65858c8e05427ac69b376e42e36d60 100644 (file)
@@ -642,24 +642,24 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        // RECURSIVE PROTECTION! BE CAREFUL HERE!
                        if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
 
-                               // Then try to search for code-templates first
-                               try {
-                                       // Load the code template and remember it's contents
-                                       $this->loadCodeTemplate($template);
-                                       $this->loadedRawData[$template] = $this->getRawTemplateData();
+                               // Template not found, but maybe variable assigned?
+                               if ($this->isVariableAlreadySet($template) !== false) {
+                                       // Use that content here
+                                       $this->loadedRawData[$template] = $this->readVariable($template);
 
-                                       // Remember this template for recursion detection
-                                       // RECURSIVE PROTECTION!
+                                       // Recursive protection:
                                        $this->loadedTemplates[] = $template;
-                               } catch (FilePointerNotOpenedException $e) {
-                                       // Template not found, but maybe variable assigned?
-                                       if ($this->isVariableAlreadySet($template) !== false) {
-                                               // Use that content here
-                                               $this->loadedRawData[$template] = $this->readVariable($template);
-
-                                               // Recursive protection:
+                               } else {
+                                       // Then try to search for code-templates
+                                       try {
+                                               // Load the code template and remember it's contents
+                                               $this->loadCodeTemplate($template);
+                                               $this->loadedRawData[$template] = $this->getRawTemplateData();
+
+                                               // Remember this template for recursion detection
+                                               // RECURSIVE PROTECTION!
                                                $this->loadedTemplates[] = $template;
-                                       } else {
+                                       } catch (FilePointerNotOpenedException $e) {
                                                // Even this is not done... :/
                                                $this->rawTemplates[] = $template;
                                        }
index 1956b02c17d14b1c0e9e27af45ab606cd0a60b73..75926e2c40eedfb0c75b96aaabff9bb4278d1f2c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,4 +1,5 @@
 <?php
+//xdebug_start_trace();
 /**
  * The main class with the entry point to the whole application. This class
  * "emulates" Java(tm)'s entry point call. Additionally it covers local