Before a filter chain is executed we check if it is there
[core.git] / inc / classes / main / controller / class_BaseController.php
index 50f57fd..2a1c50f 100644 (file)
@@ -29,6 +29,9 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         */
        private $filterChains = array();
 
+       // Exception constants
+       const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10;
+
        /**
         * Protected constructor
         *
@@ -57,7 +60,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         * @param       $filterChain    Name of the filter chain
         * @return      void
         */
-       private function initFilterChain ($filterChain) {
+       protected function initFilterChain ($filterChain) {
                $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
        }
 
@@ -101,8 +104,16 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         * @param       $requestInstance        An instance of a request class
         * @param       $responseInstance       An instance of a response class
         * @return      void
+        * @throws      InvalidFilterChainException     If the filter chain is invalid
         */
        protected function executeFilters ($filterGroup, Requestable $requestInstance, Responseable $responseInstance) {
+               // Test if the filter is there
+               if (!isset($this->filterChains[$filterGroup])) {
+                       // Throw an exception here
+                       throw new InvalidFilterChainException(array($this, $filterGroup), self::EXCEPTION_FILTER_CHAIN_INVALID);
+               } // END - if
+
+               // Run all filters
                $this->filterChains[$filterGroup]->processFilters($requestInstance, $responseInstance);
        }