3 namespace Org\Mxchange\CoreFramework\Registration;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
7 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
8 use Org\Mxchange\CoreFramework\Filter\Filterable;
9 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
12 * A general registration class.
14 * @author Roland Haeder <webmaster@shipsimu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.shipsimu.org
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 abstract class BaseRegistration extends BaseFrameworkSystem {
35 * Pre-registration filter chain
37 private $preRegistrationFilter = NULL;
40 * Pre-registration filter chain
42 private $postRegistrationFilter = NULL;
45 * Protected constructor
47 * @param $className Name of the class
50 protected function __construct ($className) {
51 // Call parent constructor
52 parent::__construct($className);
56 * Initialize filters. This must be done before you can use them
60 protected function initFilterChains () {
61 // Pre/post-registration filters
62 $this->preRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
63 $this->postRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
67 * Adds a filter to the pre filter chain
69 * @param $filterInstance An instance of a filter
72 public function addPreFilter (Filterable $filterInstance) {
74 $this->preRegistrationFilter->addFilter($filterInstance);
78 * Adds a filter to the post filter chain
80 * @param $filterInstance An instance of a filter
83 public function addPostFilter (Filterable $filterInstance) {
84 // Add the post filter
85 $this->postRegistrationFilter->addFilter($filterInstance);
89 * Executes all pre filters
93 protected function executePreFilters () {
94 // Execute all pre filters
95 $this->preRegistrationFilter->processFilters(FrameworkBootstrap::getRequestInstance(), FrameworkBootstrap::getResponseInstance());
99 * Executes all post filters
103 protected function executePostFilters () {
104 // Execute all post filters
105 $this->postRegistrationFilter->processFilters(FrameworkBootstrap::getRequestInstance(), FrameworkBootstrap::getResponseInstance());