addFilter() should also throw an InvalidFilterChainException
authorRoland Häder <roland@mxchange.org>
Sun, 2 Aug 2009 10:37:21 +0000 (10:37 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 2 Aug 2009 10:37:21 +0000 (10:37 +0000)
inc/classes/main/controller/class_BaseController.php

index 2a1c50f..95827c5 100644 (file)
@@ -70,8 +70,16 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
         * @param       $filterGroup    Group of the filter
         * @param       $filterInstance         An instance of a filter
         * @return      void
         * @param       $filterGroup    Group of the filter
         * @param       $filterInstance         An instance of a filter
         * @return      void
+        * @throws      InvalidFilterChainException     If the filter chain is invalid
         */
        protected function addFilter ($filterGroup, Filterable $filterInstance) {
         */
        protected function addFilter ($filterGroup, Filterable $filterInstance) {
+               // 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
+
+               // Add the filter
                $this->filterChains[$filterGroup]->addFilter($filterInstance);
        }
 
                $this->filterChains[$filterGroup]->addFilter($filterInstance);
        }