Some updates:
[core.git] / framework / main / classes / registration / class_BaseRegistration.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Registration;
4
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;
10
11 /**
12  * A general registration class.
13  *
14  * @author              Roland Haeder <webmaster@shipsimu.org>
15  * @version             0.0.0
16 <<<<<<< HEAD:framework/main/classes/registration/class_BaseRegistration.php
17  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
18 =======
19  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
20 >>>>>>> Some updates::inc/main/classes/registration/class_BaseRegistration.php
21  * @license             GNU GPL 3.0 or any newer version
22  * @link                http://www.shipsimu.org
23  *
24  * This program is free software: you can redistribute it and/or modify
25  * it under the terms of the GNU General Public License as published by
26  * the Free Software Foundation, either version 3 of the License, or
27  * (at your option) any later version.
28  *
29  * This program is distributed in the hope that it will be useful,
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32  * GNU General Public License for more details.
33  *
34  * You should have received a copy of the GNU General Public License
35  * along with this program. If not, see <http://www.gnu.org/licenses/>.
36  */
37 abstract class BaseRegistration extends BaseFrameworkSystem {
38         /**
39          * Pre-registration filter chain
40          */
41         private $preRegistrationFilter = NULL;
42
43         /**
44          * Pre-registration filter chain
45          */
46         private $postRegistrationFilter = NULL;
47
48         /**
49          * Protected constructor
50          *
51          * @param       $className      Name of the class
52          * @return      void
53          */
54         protected function __construct ($className) {
55                 // Call parent constructor
56                 parent::__construct($className);
57         }
58
59         /**
60          * Initialize filters. This must be done before you can use them
61          *
62          * @return      void
63          */
64         protected function initFilterChains () {
65                 // Pre/post-registration filters
66                 $this->preRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
67                 $this->postRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
68         }
69
70         /**
71          * Adds a filter to the pre filter chain
72          *
73          * @param       $filterInstance         An instance of a filter
74          * @return      void
75          */
76         public function addPreFilter (Filterable $filterInstance) {
77                 // Add the pre filter
78                 $this->preRegistrationFilter->addFilter($filterInstance);
79         }
80
81         /**
82          * Adds a filter to the post filter chain
83          *
84          * @param       $filterInstance         An instance of a filter
85          * @return      void
86          */
87         public function addPostFilter (Filterable $filterInstance) {
88                 // Add the post filter
89                 $this->postRegistrationFilter->addFilter($filterInstance);
90         }
91
92         /**
93          * Executes all pre filters
94          *
95          * @return      void
96          */
97         protected function executePreFilters () {
98                 // Execute all pre filters
99                 $this->preRegistrationFilter->processFilters(FrameworkBootstrap::getRequestInstance(), FrameworkBootstrap::getResponseInstance());
100         }
101
102         /**
103          * Executes all post filters
104          *
105          * @return      void
106          */
107         protected function executePostFilters () {
108                 // Execute all post filters
109                 $this->postRegistrationFilter->processFilters(FrameworkBootstrap::getRequestInstance(), FrameworkBootstrap::getResponseInstance());
110         }
111
112 }