X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcontroller%2Fclass_BaseController.php;h=2a1c50f97c0b5a18267c4bd067f8b1d9287941df;hp=9fd257c234fa4b908fb15c23e918c486759ead41;hb=90e103cb445f53c4ebd18c3f43dff51cbf0aae73;hpb=46f92fe63badaf1a2f2cddfaf9d3959f7787bbf2 diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php index 9fd257c2..2a1c50f9 100644 --- a/inc/classes/main/controller/class_BaseController.php +++ b/inc/classes/main/controller/class_BaseController.php @@ -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'); } @@ -68,7 +71,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { * @param $filterInstance An instance of a filter * @return void */ - protected function add addFilter ($filterGroup, Filterable $filterInstance) { + protected function addFilter ($filterGroup, Filterable $filterInstance) { $this->filterChains[$filterGroup]->addFilter($filterInstance); } @@ -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); }