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