07df56e01371920ccca535219229d96bde98dee2
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Model / Additional / AdditionalAdditionalElement.php
1 <?php
2 namespace TYPO3\CMS\Form\Domain\Model\Additional;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2008 Patrick Broens (patrick@patrickbroens.nl)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Additional elements for FORM object
28 *
29 * @author Patrick Broens <patrick@patrickbroens.nl>
30 * @package TYPO3
31 * @subpackage form
32 */
33 class AdditionalAdditionalElement {
34
35 /**
36 * Array with the additional objects of the element
37 *
38 * @var array
39 */
40 protected $additional = array();
41
42 /**
43 * Add an additional object to the additional array
44 *
45 * @param string $class Name of the additional
46 * @param mixed $value Typoscript configuration to construct value
47 * @param string $type Typoscript content object
48 * @return tx_form_Domain_Model_Additional
49 */
50 public function addAdditional($class, $type, $value) {
51 $class = strtolower((string) $class);
52 $className = 'TYPO3\\CMS\\Form\\Domain\\Model\\Additional\\' . ucfirst($class) . 'AdditionalElement';
53 $this->additional[$class] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className, $type, $value);
54 return $this;
55 }
56
57 /**
58 * Get the additional array of the object
59 *
60 * @return array Additionals of the object
61 */
62 public function getAdditional() {
63 return $this->additional;
64 }
65
66 /**
67 * Get a specific additional object by using the key
68 *
69 * @param string $key Key of the additional
70 * @return \TYPO3\CMS\Form\Domain\Model\Additional\AbstractAdditionalElement The additional object
71 */
72 public function getAdditionalObjectByKey($key) {
73 return $this->additional[$key];
74 }
75
76 /**
77 * Check if an additional is set.
78 * Returns TRUE if set, FALSE if not set.
79 *
80 * @param string $key Name of the additional
81 * @return boolean
82 */
83 public function additionalIsSet($key) {
84 return isset($this->additional[$key]);
85 }
86
87 /**
88 * Set the layout for an additional
89 *
90 * @param string $key Key for the additional
91 * @param string $layout XML string
92 * @return void
93 */
94 public function setLayout($key, $layout) {
95 $this->getAdditionalObjectByKey($key)->setLayout($layout);
96 }
97
98 /**
99 * Get a specific additional value by using the key
100 *
101 * @param string $key Key of the additional
102 * @return string The value of the additional
103 */
104 public function getValue($key) {
105 return $this->getAdditionalObjectByKey($key)->getValue();
106 }
107
108 }
109
110
111 ?>