3 namespace Org\Mxchange\CoreFramework\Resolver;
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;
11 * A generic resolver class
13 * @author Roland Haeder <webmaster@shipsimu.org>
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
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.
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.
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/>.
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;
42 private $namespace = '';
47 private $className = '';
52 private $classPrefix = '';
55 * (Last) resolved instance
57 private $resolvedInstance = NULL;
60 * A controller instance
62 private $controllerInstance = NULL;
65 * Protected constructor
67 * @param $className Real name of the class
70 protected function __construct (string $className) {
71 // Call parent constructor
72 parent::__construct($className);
76 * Getter for namespace
78 * @return $namespace Namespace to look in
80 public final function getNamespace () {
81 return $this->namespace;
85 * Setter for namespace
87 * @param $namespace Namespace to look in
90 protected final function setNamespace ($namespace) {
91 $this->namespace = (string) $namespace;
95 * Getter for class name
97 * @return $className Name of the class
99 public final function getClassName () {
100 return $this->className;
104 * Setter for class name
106 * @param $className Name of the class
109 protected final function setClassName ($className) {
110 $this->className = (string) $className;
114 * "Getter" for class name (useable for an object factory)
116 * @return $className Capitalized class name
118 protected function getCapitalizedClassPrefix () {
120 $className = $this->getClassPrefix();
123 $className = self::convertToClassName($className);
130 * Getter for class prefix
132 * @return $classPrefix Last validated classPrefix
134 protected final function getClassPrefix () {
135 return $this->classPrefix;
139 * Setter for class prefix
141 * @param $classPrefix Last validated classPrefix
144 protected final function setClassPrefix ($classPrefix) {
145 $this->classPrefix = (string) $classPrefix;
149 * Getter for (last) resolved instance
151 * @return $resolvedInstance Last validated resolvedInstance
153 protected final function getResolvedInstance () {
154 return $this->resolvedInstance;
158 * Setter for (last) resolved instance
160 * @param $resolvedInstance (Last) validated resolved instance
163 protected final function setResolvedInstance (FrameworkInterface $resolvedInstance) {
164 $this->resolvedInstance = $resolvedInstance;
168 * Setter for controller instance (this surely breaks a bit the MVC patterm)
170 * @param $controllerInstance An instance of the controller
173 public final function setControllerInstance (Controller $controllerInstance) {
174 $this->controllerInstance = $controllerInstance;
178 * Getter for controller instance (this surely breaks a bit the MVC patterm)
180 * @return $controllerInstance An instance of the controller
182 public final function getControllerInstance () {
183 return $this->controllerInstance;