Merge "[Task] Update changelog and version to 6.0.0-dev"
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Object / Container / ClassInfo.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Extbase Team
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Value object containing the relevant informations for a class,
29 * this object is build by the classInfoFactory - or could also be restored from a cache
30 *
31 * @author Daniel Pötzinger
32 */
33 class Tx_Extbase_Object_Container_ClassInfo {
34
35 /**
36 * The classname of the class where the infos belong to
37 * @var string
38 */
39 private $className;
40
41 /**
42 * The constructor Dependencies for the class in the format:
43 * array(
44 * 0 => array( <-- parameters for argument 1
45 * 'name' => <arg name>, <-- name of argument
46 * 'dependency' => <classname>, <-- if the argument is a class, the type of the argument
47 * 'defaultvalue' => <mixed>) <-- if the argument is optional, its default value
48 * ),
49 * 1 => ...
50 * )
51 *
52 * @var array
53 */
54 private $constructorArguments;
55
56 /**
57 * All setter injections in the format
58 * array (<nameOfMethod> => <classNameToInject> )
59 *
60 * @var array
61 */
62 private $injectMethods;
63
64 /**
65 * All setter injections in the format
66 * array (<nameOfProperty> => <classNameToInject> )
67 *
68 * @var array
69 */
70 private $injectProperties;
71
72 /**
73 * Indicates if the class is a singleton or not.
74 *
75 * @var boolean
76 */
77 private $isSingleton = FALSE;
78
79 /**
80 * Indicates if the class has the method initializeObject
81 *
82 * @var boolean
83 */
84 private $isInitializeable = FALSE;
85
86 /**
87 * @param string $className
88 * @param array $constructorArguments
89 * @param array $injectMethods
90 * @param boolean $isSingleton
91 * @param boolean $isInitializeable
92 * @param array $injectProperties
93 */
94 public function __construct($className, array $constructorArguments, array $injectMethods, $isSingleton = FALSE, $isInitializeable = FALSE, array $injectProperties = array()) {
95 $this->className = $className;
96 $this->constructorArguments = $constructorArguments;
97 $this->injectMethods = $injectMethods;
98 $this->injectProperties = $injectProperties;
99 $this->isSingleton = $isSingleton;
100 $this->isInitializeable = $isInitializeable;
101 }
102
103 /**
104 * Gets the class name passed to constructor
105 *
106 * @return string
107 */
108 public function getClassName() {
109 return $this->className;
110 }
111
112 /**
113 * Get arguments passed to constructor
114 *
115 * @return array
116 */
117 public function getConstructorArguments() {
118 return $this->constructorArguments;
119 }
120
121 /**
122 * Returns an array with the inject methods.
123 *
124 * @return array
125 */
126 public function getInjectMethods() {
127 return $this->injectMethods;
128 }
129
130 /**
131 * Returns an array with the inject properties
132 *
133 * @return array
134 */
135 public function getInjectProperties() {
136 return $this->injectProperties;
137 }
138
139 /**
140 * Asserts if the class is a singleton or not.
141 *
142 * @return boolean
143 */
144 public function getIsSingleton() {
145 return $this->isSingleton;
146 }
147
148 /**
149 * Asserts if the class is initializeable with initializeObject.
150 *
151 * @return boolean
152 */
153 public function getIsInitializeable() {
154 return $this->isInitializeable;
155 }
156
157 /**
158 * Asserts if the class has Dependency Injection methods
159 *
160 * @return boolean
161 */
162 public function hasInjectMethods() {
163 return (count($this->injectMethods) > 0);
164 }
165
166 /**
167 * @return boolean
168 */
169 public function hasInjectProperties() {
170 return (count($this->injectProperties) > 0);
171 }
172 }