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