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;
9 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
12 * A generic resolver class
14 * @author Roland Haeder <webmaster@shipsimu.org>
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
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.
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.
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/>.
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;
43 private $namespace = '';
48 private $className = '';
53 private $classPrefix = '';
56 * (Last) resolved instance
58 private $resolvedInstance = NULL;
61 * A controller instance
63 private $controllerInstance = NULL;
66 * Protected constructor
68 * @param $className Real name of the class
71 protected function __construct (string $className) {
72 // Call parent constructor
73 parent::__construct($className);
77 * Getter for namespace
79 * @return $namespace Namespace to look in
81 public final function getNamespace () {
82 return $this->namespace;
86 * Setter for namespace
88 * @param $namespace Namespace to look in
91 protected final function setNamespace ($namespace) {
92 $this->namespace = (string) $namespace;
96 * Getter for class name
98 * @return $className Name of the class
100 public final function getClassName () {
101 return $this->className;
105 * Setter for class name
107 * @param $className Name of the class
110 protected final function setClassName ($className) {
111 $this->className = (string) $className;
115 * "Getter" for class name (useable for an object factory)
117 * @return $className Capitalized class name
119 protected function getCapitalizedClassPrefix () {
121 $className = $this->getClassPrefix();
124 $className = StringUtils::convertToClassName($className);
131 * Getter for class prefix
133 * @return $classPrefix Last validated classPrefix
135 protected final function getClassPrefix () {
136 return $this->classPrefix;
140 * Setter for class prefix
142 * @param $classPrefix Last validated classPrefix
145 protected final function setClassPrefix ($classPrefix) {
146 $this->classPrefix = (string) $classPrefix;
150 * Getter for (last) resolved instance
152 * @return $resolvedInstance Last validated resolvedInstance
154 protected final function getResolvedInstance () {
155 return $this->resolvedInstance;
159 * Setter for (last) resolved instance
161 * @param $resolvedInstance (Last) validated resolved instance
164 protected final function setResolvedInstance (FrameworkInterface $resolvedInstance) {
165 $this->resolvedInstance = $resolvedInstance;
169 * Setter for controller instance (this surely breaks a bit the MVC patterm)
171 * @param $controllerInstance An instance of the controller
174 public final function setControllerInstance (Controller $controllerInstance) {
175 $this->controllerInstance = $controllerInstance;
179 * Getter for controller instance (this surely breaks a bit the MVC patterm)
181 * @return $controllerInstance An instance of the controller
183 public final function getControllerInstance () {
184 return $this->controllerInstance;