]> 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 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
10
11 /**
12  * A generic resolver class
13  *
14  * @author              Roland Haeder <webmaster@shipsimu.org>
15  * @version             0.0.0
16  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 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 abstract class BaseResolver extends BaseFrameworkSystem {
34         // Exception constants
35         const EXCEPTION_INVALID_COMMAND    = 0x1d0;
36         const EXCEPTION_INVALID_CONTROLLER = 0x1d1;
37         const EXCEPTION_INVALID_ACTION     = 0x1d2;
38         const EXCEPTION_INVALID_STATE      = 0x1d3;
39
40         /**
41          * Namespace
42          */
43         private $namespace = '';
44
45         /**
46          * Class name
47          */
48         private $className = '';
49
50         /**
51          * Prefix for class
52          */
53         private $classPrefix = '';
54
55         /**
56          * (Last) resolved instance
57          */
58         private $resolvedInstance = NULL;
59
60         /**
61          * A controller instance
62          */
63         private $controllerInstance = NULL;
64
65         /**
66          * Protected constructor
67          *
68          * @param       $className      Real name of the class
69          * @return      void
70          */
71         protected function __construct (string $className) {
72                 // Call parent constructor
73                 parent::__construct($className);
74         }
75
76         /**
77          * Getter for namespace
78          *
79          * @return      $namespace      Namespace to look in
80          */
81         public final function getNamespace () {
82                 return $this->namespace;
83         }
84
85         /**
86          * Setter for namespace
87          *
88          * @param       $namespace      Namespace to look in
89          * @return      void
90          */
91         protected final function setNamespace (string $namespace) {
92                 $this->namespace = $namespace;
93         }
94
95         /**
96          * Getter for class name
97          *
98          * @return      $className      Name of the class
99          */
100         public final function getClassName () {
101                 return $this->className;
102         }
103
104         /**
105          * Setter for class name
106          *
107          * @param       $className      Name of the class
108          * @return      void
109          */
110         protected final function setClassName (string $className) {
111                 $this->className = $className;
112         }
113
114         /**
115          * "Getter" for class name (useable for an object factory)
116          *
117          * @return      $className      Capitalized class name
118          */
119         protected function getCapitalizedClassPrefix () {
120                 // Get class name
121                 $className = $this->getClassPrefix();
122
123                 // And capitalize it
124                 $className = StringUtils::convertToClassName($className);
125
126                 // Return it
127                 return $className;
128         }
129
130         /**
131          * Getter for class prefix
132          *
133          * @return      $classPrefix    Last validated classPrefix
134          */
135         protected final function getClassPrefix () {
136                 return $this->classPrefix;
137         }
138
139         /**
140          * Setter for class prefix
141          *
142          * @param       $classPrefix    Last validated classPrefix
143          * @return      void
144          */
145         protected final function setClassPrefix ($classPrefix) {
146                 $this->classPrefix = (string) $classPrefix;
147         }
148
149         /**
150          * Getter for (last) resolved instance
151          *
152          * @return      $resolvedInstance       Last validated resolvedInstance
153          */
154         protected final function getResolvedInstance () {
155                 return $this->resolvedInstance;
156         }
157
158         /**
159          * Setter for (last) resolved instance
160          *
161          * @param       $resolvedInstance       (Last) validated resolved instance
162          * @return      void
163          */
164         protected final function setResolvedInstance (FrameworkInterface $resolvedInstance) {
165                 $this->resolvedInstance = $resolvedInstance;
166         }
167
168         /**
169          * Setter for controller instance (this surely breaks a bit the MVC patterm)
170          *
171          * @param       $controllerInstance             An instance of the controller
172          * @return      void
173          */
174         public final function setControllerInstance (Controller $controllerInstance) {
175                 $this->controllerInstance = $controllerInstance;
176         }
177
178         /**
179          * Getter for controller instance (this surely breaks a bit the MVC patterm)
180          *
181          * @return      $controllerInstance             An instance of the controller
182          */
183         public final function getControllerInstance () {
184                 return $this->controllerInstance;
185         }
186
187 }