TYPO3 CMS  TYPO3_6-2
ClassSchema.php
Go to the documentation of this file.
1 <?php
3 
21 class ClassSchema {
22 
26  const MODELTYPE_ENTITY = 1;
28 
34  protected $className;
35 
41  protected $modelType = self::MODELTYPE_ENTITY;
42 
48  protected $aggregateRoot = FALSE;
49 
55  protected $uuidPropertyName;
56 
62  protected $properties = array();
63 
69  protected $identityProperties = array();
70 
76 
82  public function __construct($className) {
83  $this->className = $className;
84  }
85 
91  public function getClassName() {
92  return $this->className;
93  }
94 
104  public function addProperty($name, $type, $lazy = FALSE, $cascade = '') {
105  $type = $this->typeHandlingService->parseType($type);
106  $this->properties[$name] = array(
107  'type' => $type['type'],
108  'elementType' => $type['elementType'],
109  'lazy' => $lazy,
110  'cascade' => $cascade
111  );
112  }
113 
121  public function getProperty($propertyName) {
122  return is_array($this->properties[$propertyName]) ? $this->properties[$propertyName] : array();
123  }
124 
130  public function getProperties() {
131  return $this->properties;
132  }
133 
141  public function setModelType($modelType) {
142  if ($modelType < self::MODELTYPE_ENTITY || $modelType > self::MODELTYPE_VALUEOBJECT) {
143  throw new \InvalidArgumentException('"' . $modelType . '" is an invalid model type.', 1212519195);
144  }
145  $this->modelType = $modelType;
146  }
147 
153  public function getModelType() {
154  return $this->modelType;
155  }
156 
164  public function setAggregateRoot($isRoot) {
165  $this->aggregateRoot = $isRoot;
166  }
167 
174  public function isAggregateRoot() {
175  return $this->aggregateRoot;
176  }
177 
184  public function hasProperty($propertyName) {
185  return array_key_exists($propertyName, $this->properties);
186  }
187 
195  public function setUuidPropertyName($propertyName) {
196  if (!array_key_exists($propertyName, $this->properties)) {
197  throw new \InvalidArgumentException('Property "' . $propertyName . '" must be added to the class schema before it can be marked as UUID property.', 1233863842);
198  }
199  $this->uuidPropertyName = $propertyName;
200  }
201 
207  public function getUuidPropertyName() {
209  }
210 
220  public function markAsIdentityProperty($propertyName) {
221  if (!array_key_exists($propertyName, $this->properties)) {
222  throw new \InvalidArgumentException('Property "' . $propertyName . '" must be added to the class schema before it can be marked as identity property.', 1233775407);
223  }
224  if ($this->properties[$propertyName]['lazy'] === TRUE) {
225  throw new \InvalidArgumentException('Property "' . $propertyName . '" must not be makred for lazy loading to be marked as identity property.', 1239896904);
226  }
227  $this->identityProperties[$propertyName] = $this->properties[$propertyName]['type'];
228  }
229 
236  public function getIdentityProperties() {
238  }
239 }
addProperty($name, $type, $lazy=FALSE, $cascade='')