More concrete exceptions added, BaseController rewritten:
[core.git] / inc / classes / main / controller / class_BaseController.php
index ba28c2768da76e5da26aa0751991feef8bbb4544..44be9968aad22c8a488dc39f9480e299745e6504 100644 (file)
@@ -32,6 +32,10 @@ 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';
+
        /**
         * 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);
@@ -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);
        }
 }