]> git.mxchange.org Git - core.git/blob - framework/main/classes/resolver/class_BaseResolver.php
Continued:
[core.git] / framework / main / classes / resolver / class_BaseResolver.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Resolver;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Controller\Controller;
7 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
8 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
9
10 /**
11  * A generic resolver class
12  *
13  * @author              Roland Haeder <webmaster@shipsimu.org>
14  * @version             0.0.0
15  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
16  * @license             GNU GPL 3.0 or any newer version
17  * @link                http://www.shipsimu.org
18  *
19  * This program is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  */
32 abstract class BaseResolver extends BaseFrameworkSystem {
33         // Exception constants
34         const EXCEPTION_INVALID_COMMAND    = 0x1d0;
35         const EXCEPTION_INVALID_CONTROLLER = 0x1d1;
36         const EXCEPTION_INVALID_ACTION     = 0x1d2;
37         const EXCEPTION_INVALID_STATE      = 0x1d3;
38
39         /**
40          * Namespace
41          */
42         private $namespace = '';
43
44         /**
45          * Class name
46          */
47         private $className = '';
48
49         /**
50          * Prefix for class
51          */
52         private $classPrefix = '';
53
54         /**
55          * (Last) resolved instance
56          */
57         private $resolvedInstance = NULL;
58
59         /**
60          * A controller instance
61          */
62         private $controllerInstance = NULL;
63
64         /**
65          * Protected constructor
66          *
67          * @param       $className      Real name of the class
68          * @return      void
69          */
70         protected function __construct (string $className) {
71                 // Call parent constructor
72                 parent::__construct($className);
73         }
74
75         /**
76          * Getter for namespace
77          *
78          * @return      $namespace      Namespace to look in
79          */
80         public final function getNamespace () {
81                 return $this->namespace;
82         }
83
84         /**
85          * Setter for namespace
86          *
87          * @param       $namespace      Namespace to look in
88          * @return      void
89          */
90         protected final function setNamespace ($namespace) {
91                 $this->namespace = (string) $namespace;
92         }
93
94         /**
95          * Getter for class name
96          *
97          * @return      $className      Name of the class
98          */
99         public final function getClassName () {
100                 return $this->className;
101         }
102
103         /**
104          * Setter for class name
105          *
106          * @param       $className      Name of the class
107          * @return      void
108          */
109         protected final function setClassName ($className) {
110                 $this->className = (string) $className;
111         }
112
113         /**
114          * "Getter" for class name (useable for an object factory)
115          *
116          * @return      $className      Capitalized class name
117          */
118         protected function getCapitalizedClassPrefix () {
119                 // Get class name
120                 $className = $this->getClassPrefix();
121
122                 // And capitalize it
123                 $className = self::convertToClassName($className);
124
125                 // Return it
126                 return $className;
127         }
128
129         /**
130          * Getter for class prefix
131          *
132          * @return      $classPrefix    Last validated classPrefix
133          */
134         protected final function getClassPrefix () {
135                 return $this->classPrefix;
136         }
137
138         /**
139          * Setter for class prefix
140          *
141          * @param       $classPrefix    Last validated classPrefix
142          * @return      void
143          */
144         protected final function setClassPrefix ($classPrefix) {
145                 $this->classPrefix = (string) $classPrefix;
146         }
147
148         /**
149          * Getter for (last) resolved instance
150          *
151          * @return      $resolvedInstance       Last validated resolvedInstance
152          */
153         protected final function getResolvedInstance () {
154                 return $this->resolvedInstance;
155         }
156
157         /**
158          * Setter for (last) resolved instance
159          *
160          * @param       $resolvedInstance       (Last) validated resolved instance
161          * @return      void
162          */
163         protected final function setResolvedInstance (FrameworkInterface $resolvedInstance) {
164                 $this->resolvedInstance = $resolvedInstance;
165         }
166
167         /**
168          * Setter for controller instance (this surely breaks a bit the MVC patterm)
169          *
170          * @param       $controllerInstance             An instance of the controller
171          * @return      void
172          */
173         public final function setControllerInstance (Controller $controllerInstance) {
174                 $this->controllerInstance = $controllerInstance;
175         }
176
177         /**
178          * Getter for controller instance (this surely breaks a bit the MVC patterm)
179          *
180          * @return      $controllerInstance             An instance of the controller
181          */
182         public final function getControllerInstance () {
183                 return $this->controllerInstance;
184         }
185
186 }