Feature #3293 » fluid_3293.patch

adds utility class and simple testcase - Christian Müller, 2009-06-08 17:50

View differences:

typo3/sysext/extbase/Classes/Utility/TypoScript.php (revision 0)
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2009 Christian M?ller <christian@kitsunet.de>
6
*  All rights reserved
7
*
8
*  This script is part of the TYPO3 project. The TYPO3 project is
9
*  free software; you can redistribute it and/or modify
10
*  it under the terms of the GNU General Public License as published by
11
*  the Free Software Foundation; either version 2 of the License, or
12
*  (at your option) any later version.
13
*
14
*  The GNU General Public License can be found at
15
*  http://www.gnu.org/copyleft/gpl.html.
16
*
17
*  This script is distributed in the hope that it will be useful,
18
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
*  GNU General Public License for more details.
21
*
22
*  This copyright notice MUST APPEAR in all copies of the script!
23
***************************************************************/
24

  
25
/**
26
 * Utilities to manage and convert Typoscript Code
27
 *
28
 * @package Extbase
29
 * @subpackage extbase
30
 * @version $ID:$
31
 */
32
class Tx_Extbase_Utility_TypoScript {
33

  
34
	/**
35
	 * Returns an array with Typoscript the old way (with dot)
36
	 * @param array $extBaseTS An Typoscript Array with extBase Syntax (without dot but with _typoscriptNodeValue)
37
	 * @return array array with Typoscript as usual (with dot)
38
	 */
39
	public function convertExtbaseToClassicTS($extBaseTS) {
40
		$classicTS = array();
41
		if(is_array($extBaseTS)) {
42
			foreach($extBaseTS as $key => $value) {
43
				if(is_array($value)) {
44
					if(isset($value['_typoscriptNodeValue'])){
45
						$classicTS[$key] = $value['_typoscriptNodeValue'];
46
						unset($value['_typoscriptNodeValue']);
47
					}
48
					$classicTS[$key.'.'] = Tx_Extbase_Utility_TypoScript::convertExtbaseToClassicTS($value);
49
				} else{
50
					$classicTS[$key] = $value;
51
				}
52
			}
53
		}
54
		return $classicTS;
55
	}
56
}
57
?>
typo3/sysext/extbase/Tests/Utility/TypoScript_testcase.php (revision 0)
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2009 Christian M?ller <christian@kitsunet.de>
6
*  All rights reserved
7
*
8
*  This script is part of the TYPO3 project. The TYPO3 project is
9
*  free software; you can redistribute it and/or modify
10
*  it under the terms of the GNU General Public License as published by
11
*  the Free Software Foundation; either version 2 of the License, or
12
*  (at your option) any later version.
13
*
14
*  The GNU General Public License can be found at
15
*  http://www.gnu.org/copyleft/gpl.html.
16
*
17
*  This script is distributed in the hope that it will be useful,
18
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
*  GNU General Public License for more details.
21
*
22
*  This copyright notice MUST APPEAR in all copies of the script!
23
***************************************************************/
24

  
25

  
26
/**
27
 * Testcase for class Tx_Extbase_Utility_TypoScript
28
 *
29
 * @package Extbase
30
 * @subpackage extbase
31
 */
32

  
33
class Tx_Extbase_Utility_TypoScript_testcase extends tx_phpunit_testcase {
34

  
35
	/**
36
	 * @test
37
	 * @see Tx_Extbase_Utility_TypoScript::convertExtbaseToClassicTS
38
	 */
39
	public function basicExtBase2ClassicTest(){
40

  
41
		$extBase = array(
42
			'10' => array(
43
				'value' => 'Hallo',
44
				'_typoscriptNodeValue' => 'TEXT'
45
			)
46
		);
47

  
48
		$classic = array(
49
			'10' => 'TEXT',
50
			'10.' => array(
51
				'value' => 'Hallo'
52
			)
53
		);
54

  
55
		$converted = Tx_Extbase_Utility_TypoScript::convertExtbaseToClassicTS($extBase);
56

  
57
		$this->assertEquals($converted, $classic);
58
	}
59

  
60

  
61
}
62

  
63
?>
    (1-1/1)