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