| 86 | | protected $cdata = null; |
|---|
| 87 | | /** |
|---|
| 88 | | * the class loader to use |
|---|
| 89 | | * |
|---|
| 90 | | * @var XJConfClassLoader |
|---|
| 91 | | */ |
|---|
| 92 | | protected $classLoader = null; |
|---|
| 93 | | /** |
|---|
| 94 | | * list of simple types where the class loader can not be applied to |
|---|
| 95 | | * |
|---|
| 96 | | * @var array<string> |
|---|
| 97 | | */ |
|---|
| 98 | | protected $simpleTypes = array('boolean', 'bool', 'integer', 'int', 'double', 'float', 'string', 'array'); |
|---|
| 99 | | /** |
|---|
| 100 | | * Whether the calls should be made statically or not |
|---|
| 101 | | * |
|---|
| 102 | | * @var boolean |
|---|
| 103 | | */ |
|---|
| 104 | | protected $static = false; |
|---|
| 105 | | |
|---|
| 106 | | /** |
|---|
| 107 | | * set the name of the value |
|---|
| 108 | | * |
|---|
| 109 | | * @param string $name |
|---|
| 110 | | */ |
|---|
| 111 | | public function setName($name) |
|---|
| 112 | | { |
|---|
| 113 | | $this->name = $name; |
|---|
| 114 | | } |
|---|
| 115 | | |
|---|
| 116 | | /** |
|---|
| 117 | | * get the name of the value |
|---|
| 118 | | * |
|---|
| 119 | | * @return string |
|---|
| 120 | | */ |
|---|
| 121 | | public function getName() |
|---|
| 122 | | { |
|---|
| 123 | | return $this->name; |
|---|
| 124 | | } |
|---|
| 125 | | |
|---|
| 126 | | /** |
|---|
| 127 | | * Set the type of the tag |
|---|
| 128 | | * |
|---|
| 129 | | * @param string $type |
|---|
| 130 | | */ |
|---|
| 131 | | public function setType($type) |
|---|
| 132 | | { |
|---|
| 133 | | $this->type = $type; |
|---|
| 134 | | } |
|---|
| 135 | | |
|---|
| 136 | | /** |
|---|
| 137 | | * get the type of the tag |
|---|
| 138 | | * |
|---|
| 139 | | * @return string |
|---|
| 140 | | */ |
|---|
| 141 | | public function getType() |
|---|
| 142 | | { |
|---|
| 143 | | if (null != $this->classLoader) { |
|---|
| 144 | | return $this->classLoader->getType($this->type); |
|---|
| 145 | | } |
|---|
| 146 | | |
|---|
| 147 | | return $this->type; |
|---|
| 148 | | } |
|---|
| 149 | | |
|---|
| 150 | | /** |
|---|
| 151 | | * Set whether calls should be made statically (true) |
|---|
| 152 | | * or an instance of the class should be created (false) |
|---|
| 153 | | * |
|---|
| 154 | | * @param boolean $static |
|---|
| 155 | | */ |
|---|
| 156 | | public function setStatic($static) { |
|---|
| 157 | | $this->static = $static; |
|---|
| 158 | | } |
|---|
| 159 | | |
|---|
| 160 | | /** |
|---|
| 161 | | * get the type of the tag |
|---|
| 162 | | * |
|---|
| 163 | | * @return string |
|---|
| 164 | | */ |
|---|
| 165 | | public function isStatic() |
|---|
| 166 | | { |
|---|
| 167 | | return $this->static; |
|---|
| 168 | | } |
|---|
| 169 | | |
|---|
| 170 | | /** |
|---|
| 171 | | * Convert the value of the tag. |
|---|
| 172 | | * |
|---|
| 173 | | * @param Tag $tag tag that will be converted |
|---|
| 174 | | * @return mixed converted value |
|---|
| 175 | | * @throws ValueConversionException |
|---|
| 176 | | */ |
|---|
| 177 | | public function convertValue(Tag $tag) |
|---|
| 178 | | { |
|---|
| 179 | | // get the data |
|---|
| 180 | | $data = $tag->getContent(); |
|---|
| 181 | | if (null == $data) { |
|---|
| 182 | | $data = ''; |
|---|
| 183 | | } |
|---|
| | 86 | protected $cdata = null; |
|---|
| | 87 | /** |
|---|
| | 88 | * the class loader to use |
|---|
| | 89 | * |
|---|
| | 90 | * @var XJConfClassLoader |
|---|
| | 91 | */ |
|---|
| | 92 | protected $classLoader = null; |
|---|
| | 93 | /** |
|---|
| | 94 | * list of simple types where the class loader can not be applied to |
|---|
| | 95 | * |
|---|
| | 96 | * @var array<string> |
|---|
| | 97 | */ |
|---|
| | 98 | protected $simpleTypes = array('boolean', 'bool', 'integer', 'int', 'double', 'float', 'string', 'array'); |
|---|
| | 99 | /** |
|---|
| | 100 | * Whether the calls should be made statically or not |
|---|
| | 101 | * |
|---|
| | 102 | * @var boolean |
|---|
| | 103 | */ |
|---|
| | 104 | protected $static = false; |
|---|
| | 105 | |
|---|
| | 106 | /** |
|---|
| | 107 | * set the name of the value |
|---|
| | 108 | * |
|---|
| | 109 | * @param string $name |
|---|
| | 110 | */ |
|---|
| | 111 | public function setName($name) |
|---|
| | 112 | { |
|---|
| | 113 | $this->name = $name; |
|---|
| | 114 | } |
|---|
| | 115 | |
|---|
| | 116 | /** |
|---|
| | 117 | * get the name of the value |
|---|
| | 118 | * |
|---|
| | 119 | * @return string |
|---|
| | 120 | */ |
|---|
| | 121 | public function getName() |
|---|
| | 122 | { |
|---|
| | 123 | return $this->name; |
|---|
| | 124 | } |
|---|
| | 125 | |
|---|
| | 126 | /** |
|---|
| | 127 | * Set the type of the tag |
|---|
| | 128 | * |
|---|
| | 129 | * @param string $type |
|---|
| | 130 | */ |
|---|
| | 131 | public function setType($type) |
|---|
| | 132 | { |
|---|
| | 133 | $this->type = $type; |
|---|
| | 134 | } |
|---|
| | 135 | |
|---|
| | 136 | /** |
|---|
| | 137 | * get the type of the tag |
|---|
| | 138 | * |
|---|
| | 139 | * @return string |
|---|
| | 140 | */ |
|---|
| | 141 | public function getType() |
|---|
| | 142 | { |
|---|
| | 143 | if (null != $this->classLoader) { |
|---|
| | 144 | return $this->classLoader->getType($this->type); |
|---|
| | 145 | } |
|---|
| | 146 | |
|---|
| | 147 | return $this->type; |
|---|
| | 148 | } |
|---|
| | 149 | |
|---|
| | 150 | /** |
|---|
| | 151 | * Set whether calls should be made statically (true) |
|---|
| | 152 | * or an instance of the class should be created (false) |
|---|
| | 153 | * |
|---|
| | 154 | * @param boolean $static |
|---|
| | 155 | */ |
|---|
| | 156 | public function setStatic($static) { |
|---|
| | 157 | $this->static = $static; |
|---|
| | 158 | } |
|---|
| | 159 | |
|---|
| | 160 | /** |
|---|
| | 161 | * get the type of the tag |
|---|
| | 162 | * |
|---|
| | 163 | * @return string |
|---|
| | 164 | */ |
|---|
| | 165 | public function isStatic() |
|---|
| | 166 | { |
|---|
| | 167 | return $this->static; |
|---|
| | 168 | } |
|---|
| | 169 | |
|---|
| | 170 | /** |
|---|
| | 171 | * Convert the value of the tag. |
|---|
| | 172 | * |
|---|
| | 173 | * @param Tag $tag tag that will be converted |
|---|
| | 174 | * @return mixed converted value |
|---|
| | 175 | * @throws ValueConversionException |
|---|
| | 176 | */ |
|---|
| | 177 | public function convertValue(Tag $tag) |
|---|
| | 178 | { |
|---|
| | 179 | // get the data |
|---|
| | 180 | $data = $tag->getContent(); |
|---|
| | 181 | if (null == $data) { |
|---|
| | 182 | $data = ''; |
|---|
| | 183 | } |
|---|
| 207 | | * Set the setter method |
|---|
| 208 | | * |
|---|
| 209 | | * @param string $setter name of the setter method |
|---|
| 210 | | */ |
|---|
| 211 | | public function setSetterMethod($setter) |
|---|
| 212 | | { |
|---|
| 213 | | $this->setter = $setter; |
|---|
| 214 | | } |
|---|
| 215 | | |
|---|
| 216 | | /** |
|---|
| 217 | | * Get the name of the setter method that should be used |
|---|
| 218 | | * |
|---|
| 219 | | * @return string |
|---|
| 220 | | */ |
|---|
| 221 | | public function getSetterMethod(Tag $tag) |
|---|
| 222 | | { |
|---|
| 223 | | if (null != $this->setter) { |
|---|
| 224 | | return $this->setter; |
|---|
| 225 | | } |
|---|
| 226 | | |
|---|
| 227 | | // no name, the parent should be a collection |
|---|
| 228 | | if ('__none' == $this->name) { |
|---|
| 229 | | return null; |
|---|
| 230 | | } |
|---|
| 231 | | |
|---|
| 232 | | return 'set' . ucfirst($this->getKey($tag)); |
|---|
| 233 | | } |
|---|
| | 207 | * Set the setter method |
|---|
| | 208 | * |
|---|
| | 209 | * @param string $setter name of the setter method |
|---|
| | 210 | */ |
|---|
| | 211 | public function setSetterMethod($setter) |
|---|
| | 212 | { |
|---|
| | 213 | $this->setter = $setter; |
|---|
| | 214 | } |
|---|
| | 215 | |
|---|
| | 216 | /** |
|---|
| | 217 | * Get the name of the setter method that should be used |
|---|
| | 218 | * |
|---|
| | 219 | * @return string |
|---|
| | 220 | */ |
|---|
| | 221 | public function getSetterMethod(Tag $tag) |
|---|
| | 222 | { |
|---|
| | 223 | if (null != $this->setter) { |
|---|
| | 224 | return $this->setter; |
|---|
| | 225 | } |
|---|
| | 226 | |
|---|
| | 227 | // no name, the parent should be a collection |
|---|
| | 228 | if ('__none' == $this->name) { |
|---|
| | 229 | return null; |
|---|
| | 230 | } |
|---|
| | 231 | |
|---|
| | 232 | return 'set' . ucfirst($this->getKey($tag)); |
|---|
| | 233 | } |
|---|
| 334 | | /** |
|---|
| 335 | | * Add an attribute to the tag |
|---|
| 336 | | * |
|---|
| 337 | | * @param AttributeDefinition $att |
|---|
| 338 | | */ |
|---|
| 339 | | public function addAttribute(AttributeDefinition $att) |
|---|
| 340 | | { |
|---|
| 341 | | array_push($this->atts, $att); |
|---|
| 342 | | } |
|---|
| 343 | | |
|---|
| 344 | | /** |
|---|
| 345 | | * Return list of attributes for this tag |
|---|
| 346 | | * |
|---|
| 347 | | * @return array |
|---|
| 348 | | */ |
|---|
| 349 | | public function getAttributes() { |
|---|
| 350 | | return $this->atts; |
|---|
| 351 | | } |
|---|
| 352 | | |
|---|
| 353 | | /** |
|---|
| 354 | | * Set the name of the tag |
|---|
| 355 | | * |
|---|
| 356 | | * @param name |
|---|
| 357 | | */ |
|---|
| 358 | | public function setTagName($name) |
|---|
| 359 | | { |
|---|
| 360 | | $this->tagName = $name; |
|---|
| 361 | | } |
|---|
| 362 | | |
|---|
| 363 | | /** |
|---|
| 364 | | * Set the attribute that will be used as key. |
|---|
| 365 | | * |
|---|
| 366 | | * @return name of the value |
|---|
| 367 | | */ |
|---|
| 368 | | public function setKeyAttribute($att) |
|---|
| 369 | | { |
|---|
| | 334 | /** |
|---|
| | 335 | * Add an attribute to the tag |
|---|
| | 336 | * |
|---|
| | 337 | * @param AttributeDefinition $att |
|---|
| | 338 | */ |
|---|
| | 339 | public function addAttribute(AttributeDefinition $att) |
|---|
| | 340 | { |
|---|
| | 341 | array_push($this->atts, $att); |
|---|
| | 342 | } |
|---|
| | 343 | |
|---|
| | 344 | /** |
|---|
| | 345 | * Return list of attributes for this tag |
|---|
| | 346 | * |
|---|
| | 347 | * @return array |
|---|
| | 348 | */ |
|---|
| | 349 | public function getAttributes() |
|---|
| | 350 | { |
|---|
| | 351 | return $this->atts; |
|---|
| | 352 | } |
|---|
| | 353 | |
|---|
| | 354 | /** |
|---|
| | 355 | * Set the name of the tag |
|---|
| | 356 | * |
|---|
| | 357 | * @param name |
|---|
| | 358 | */ |
|---|
| | 359 | public function setTagName($name) |
|---|
| | 360 | { |
|---|
| | 361 | $this->tagName = $name; |
|---|
| | 362 | } |
|---|
| | 363 | |
|---|
| | 364 | /** |
|---|
| | 365 | * Set the attribute that will be used as key. |
|---|
| | 366 | * |
|---|
| | 367 | * @return name of the value |
|---|
| | 368 | */ |
|---|
| | 369 | public function setKeyAttribute($att) |
|---|
| | 370 | { |
|---|
| 371 | | $this->nameAttribute = $att; |
|---|
| 372 | | } |
|---|
| 373 | | |
|---|
| 374 | | /** |
|---|
| 375 | | * get the name of the tag |
|---|
| 376 | | * |
|---|
| 377 | | * @return string |
|---|
| 378 | | */ |
|---|
| 379 | | public function getTagName() |
|---|
| 380 | | { |
|---|
| 381 | | return $this->tagName; |
|---|
| 382 | | } |
|---|
| 383 | | |
|---|
| 384 | | /** |
|---|
| 385 | | * get the name of the tag |
|---|
| 386 | | * |
|---|
| 387 | | * @return string |
|---|
| 388 | | */ |
|---|
| 389 | | public function getKey(DefinedTag $tag) |
|---|
| 390 | | { |
|---|
| 391 | | if ('__attribute' == $this->name) { |
|---|
| 392 | | return $tag->getAttribute($this->nameAttribute); |
|---|
| | 372 | $this->nameAttribute = $att; |
|---|
| | 373 | } |
|---|
| | 374 | |
|---|
| | 375 | /** |
|---|
| | 376 | * get the name of the tag |
|---|
| | 377 | * |
|---|
| | 378 | * @return string |
|---|
| | 379 | */ |
|---|
| | 380 | public function getTagName() |
|---|
| | 381 | { |
|---|
| | 382 | return $this->tagName; |
|---|
| | 383 | } |
|---|
| | 384 | |
|---|
| | 385 | /** |
|---|
| | 386 | * get the name of the tag |
|---|
| | 387 | * |
|---|
| | 388 | * @return string |
|---|
| | 389 | */ |
|---|
| | 390 | public function getKey(DefinedTag $tag) |
|---|
| | 391 | { |
|---|
| | 392 | if ('__attribute' == $this->name) { |
|---|
| | 393 | return $tag->getAttribute($this->nameAttribute); |
|---|
| 401 | | * @return boolean |
|---|
| 402 | | */ |
|---|
| 403 | | public function supportsIndexedChildren() |
|---|
| 404 | | { |
|---|
| 405 | | if ($this->getType() == 'array') { |
|---|
| 406 | | return true; |
|---|
| 407 | | } |
|---|
| 408 | | |
|---|
| 409 | | return false; |
|---|
| 410 | | } |
|---|
| 411 | | |
|---|
| 412 | | /** |
|---|
| 413 | | * set the class loader for this tag |
|---|
| 414 | | * |
|---|
| 415 | | * @param XJConfClassLoader $classLoader |
|---|
| 416 | | */ |
|---|
| 417 | | public function setClassLoader(XJConfClassLoader $classLoader) |
|---|
| 418 | | { |
|---|
| 419 | | $this->classLoader = $classLoader; |
|---|
| 420 | | } |
|---|
| | 402 | * @return boolean |
|---|
| | 403 | */ |
|---|
| | 404 | public function supportsIndexedChildren() |
|---|
| | 405 | { |
|---|
| | 406 | if ($this->getType() == 'array') { |
|---|
| | 407 | return true; |
|---|
| | 408 | } |
|---|
| | 409 | |
|---|
| | 410 | return false; |
|---|
| | 411 | } |
|---|
| | 412 | |
|---|
| | 413 | /** |
|---|
| | 414 | * set the class loader for this tag |
|---|
| | 415 | * |
|---|
| | 416 | * @param XJConfClassLoader $classLoader |
|---|
| | 417 | */ |
|---|
| | 418 | public function setClassLoader(XJConfClassLoader $classLoader) |
|---|
| | 419 | { |
|---|
| | 420 | $this->classLoader = $classLoader; |
|---|
| | 421 | } |
|---|
| | 422 | |
|---|
| | 423 | /** |
|---|
| | 424 | * extends itsself from another tag definition |
|---|
| | 425 | * |
|---|
| | 426 | * @param TagDefinition $tagDefinition the tag definition to extend from |
|---|
| | 427 | */ |
|---|
| | 428 | public function extend(self $tagDefinition) |
|---|
| | 429 | { |
|---|
| | 430 | $this->atts = $tagDefinition->getAttributes(); |
|---|
| | 431 | $childDefs = $tagDefinition->getChildDefinitions(); |
|---|
| | 432 | foreach ($childDefs as $childDef) { |
|---|
| | 433 | $this->addChildDefinition($childDef); |
|---|
| | 434 | } |
|---|
| | 435 | } |
|---|