f2a78f20abc01da93e4994d4ab87dbd70ece8a48
[core.git] / framework / main / classes / registration / class_BaseRegistration.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Registration;
4
5 // Import framework stuff
6 use CoreFramework\Bootstrap\FrameworkBootstrap;
7 use CoreFramework\Factory\ObjectFactory;
8 use CoreFramework\Filter\Filterable;
9 use CoreFramework\Object\BaseFrameworkSystem;
10
11 /**
12  * A general registration class.
13  *
14  * @author              Roland Haeder <webmaster@shipsimu.org>
15  * @version             0.0.0
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
19  *
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.
24  *
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.
29  *
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/>.
32  */
33 class BaseRegistration extends BaseFrameworkSystem {
34         /**
35          * Pre-registration filter chain
36          */
37         private $preRegistrationFilter = NULL;
38
39         /**
40          * Pre-registration filter chain
41          */
42         private $postRegistrationFilter = NULL;
43
44         /**
45          * Protected constructor
46          *
47          * @param       $className      Name of the class
48          * @return      void
49          */
50         protected function __construct ($className) {
51                 // Call parent constructor
52                 parent::__construct($className);
53         }
54
55         /**
56          * Initialize filters. This must be done before you can use them
57          *
58          * @return      void
59          */
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');
64         }
65
66         /**
67          * Adds a filter to the pre filter chain
68          *
69          * @param       $filterInstance         An instance of a filter
70          * @return      void
71          */
72         public function addPreFilter (Filterable $filterInstance) {
73                 // Add the pre filter
74                 $this->preRegistrationFilter->addFilter($filterInstance);
75         }
76
77         /**
78          * Adds a filter to the post filter chain
79          *
80          * @param       $filterInstance         An instance of a filter
81          * @return      void
82          */
83         public function addPostFilter (Filterable $filterInstance) {
84                 // Add the post filter
85                 $this->postRegistrationFilter->addFilter($filterInstance);
86         }
87
88         /**
89          * Executes all pre filters
90          *
91          * @return      void
92          */
93         protected function executePreFilters () {
94                 // Execute all pre filters
95                 $this->preRegistrationFilter->processFilters(FrameworkBootstrap::getRequestInstance(), FrameworkBootstrap::getResponseInstance());
96         }
97
98         /**
99          * Executes all post filters
100          *
101          * @return      void
102          */
103         protected function executePostFilters () {
104                 // Execute all post filters
105                 $this->postRegistrationFilter->processFilters(FrameworkBootstrap::getRequestInstance(), FrameworkBootstrap::getResponseInstance());
106         }
107
108 }