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