Updated domain without a dash :(
[core.git] / inc / classes / main / controller / class_BaseController.php
index 825727dd5f101a487b266fec9f962144be0d4a74..ef187e9cd4f58f68810ce5788a80e166bebff394 100644 (file)
@@ -4,11 +4,11 @@
  * write your own controller. You get the advantage that you can use the pre and
  * post filters.
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseController extends BaseFrameworkSystem implements Registerable {
+       // Exception constants
+       const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10;
+
+       // Names of controller's own filter chains
+       const FILTER_CHAIN_PRE_COMMAND  = 'controller_pre_command';
+       const FILTER_CHAIN_POST_COMMAND = 'controller_post_command';
+
        /**
         * Generic filter chains
         */
        private $filterChains = array();
 
-       // Exception constants
-       const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10;
-
        /**
         * Protected constructor
         *
@@ -43,8 +47,8 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
                parent::__construct($className);
 
                // Initialize both filter chains
-               $this->initFilterChain('pre');
-               $this->initFilterChain('post');
+               $this->initFilterChain(self::FILTER_CHAIN_PRE_COMMAND);
+               $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND);
 
                // Add this controller to the registry
                Registry::getRegistry()->addInstance('controller', $this);
@@ -57,9 +61,9 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         * @return      void
         */
        protected function initFilterChain ($filterChain) {
-               //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ' init: START');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START');
                $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
-               //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED');
        }
 
        /**
@@ -71,7 +75,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         * @throws      InvalidFilterChainException     If the filter chain is invalid
         */
        protected function addFilter ($filterChain, Filterable $filterInstance) {
-               //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START');
 
                // Test if the filter is there
                if (!isset($this->filterChains[$filterChain])) {
@@ -81,7 +85,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
 
                // Add the filter
                $this->filterChains[$filterChain]->addFilter($filterInstance);
-               //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH');
        }
 
        /**
@@ -92,7 +96,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         */
        public function addPreFilter (Filterable $filterInstance) {
                // Add the pre filter
-               $this->addFilter('pre', $filterInstance);
+               $this->addFilter(self::FILTER_CHAIN_PRE_COMMAND, $filterInstance);
        }
 
        /**
@@ -103,7 +107,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         */
        public function addPostFilter (Filterable $filterInstance) {
                // Add the post filter
-               $this->addFilter('post', $filterInstance);
+               $this->addFilter(self::FILTER_CHAIN_POST_COMMAND, $filterInstance);
        }
 
        /**
@@ -135,7 +139,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         */
        protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
                // Execute all pre filters
-               $this->executeFilters('pre', $requestInstance, $responseInstance);
+               $this->executeFilters(self::FILTER_CHAIN_PRE_COMMAND, $requestInstance, $responseInstance);
        }
 
        /**
@@ -147,7 +151,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         */
        protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
                // Execute all post filters
-               $this->executeFilters('post', $requestInstance, $responseInstance);
+               $this->executeFilters(self::FILTER_CHAIN_POST_COMMAND, $requestInstance, $responseInstance);
        }
 }