[BUGFIX] ConfigurationManager use FrontendSimulator only if neccessary
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Property / TypeConverter / ObjectStorageConverter.php
1 <?php
2
3 /* *
4 * This script belongs to the Extbase framework *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 * Converter which transforms arrays to arrays.
25 *
26 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
27 * @api
28 */
29 class Tx_Extbase_Property_TypeConverter_ObjectStorageConverter extends Tx_Extbase_Property_TypeConverter_AbstractTypeConverter implements t3lib_Singleton {
30
31 /**
32 * @var array<string>
33 */
34 protected $sourceTypes = array('string', 'array');
35
36 /**
37 * @var string
38 */
39 protected $targetType = 'Tx_Extbase_Persistence_ObjectStorage';
40
41 /**
42 * @var integer
43 */
44 protected $priority = 1;
45
46 /**
47 * Returns the source, if it is an array, otherwise an empty array.
48 *
49 * @return array
50 * @api
51 */
52 public function getSourceChildPropertiesToBeConverted($source) {
53 if (is_array($source)) {
54 return $source;
55 }
56 return array();
57 }
58
59 /**
60 * Actually convert from $source to $targetType, in fact a noop here.
61 *
62 * @param array $source
63 * @param string $targetType
64 * @param array $convertedChildProperties
65 * @param Tx_Extbase_Property_PropertyMappingConfigurationInterface $configuration
66 * @return array
67 * @api
68 */
69 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), Tx_Extbase_Property_PropertyMappingConfigurationInterface $configuration = NULL) {
70 $objectStorage = new Tx_Extbase_Persistence_ObjectStorage();
71
72 foreach ($convertedChildProperties as $subProperty) {
73 $objectStorage->attach($subProperty);
74 }
75
76 return $objectStorage;
77 }
78
79 /**
80 * Return the type of a given sub-property inside the $targetType
81 *
82 * @param string $targetType
83 * @param string $propertyName
84 * @param Tx_Extbase_Property_PropertyMappingConfigurationInterface $configuration
85 * @return string
86 * @api
87 */
88 public function getTypeOfChildProperty($targetType, $propertyName, Tx_Extbase_Property_PropertyMappingConfigurationInterface $configuration) {
89 $parsedTargetType = Tx_Extbase_Utility_TypeHandling::parseType($targetType);
90 return $parsedTargetType['elementType'];
91 }
92 }
93 ?>