Passed
Push — master ( fa79ba...4fcbee )
by Aimeos
08:39 queued 05:58
created

Typo3::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 3
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2022
6
 * @package MW
7
 * @subpackage View
8
 */
9
10
11
namespace Aimeos\Base\View\Engine;
12
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
13
14
15
/**
16
 * TYPO3 view engine implementation
17
 *
18
 * @package MW
19
 * @subpackage View
20
 */
21
class Typo3 implements Iface
22
{
23
	private $objectManager;
24
25
	private $configuration;
26
27
	/**
28
	 * Initializes the view object
29
	 *
30
	 * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager TYPO3 object manager
31
	 */
32
	public function __construct( \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager )
33
	{
34
		$this->objectManager = $objectManager;
35
		$this->configuration = $this->objectManager->get( ConfigurationManager::class )->getConfiguration( ConfigurationManager::CONFIGURATION_TYPE_FRAMEWORK );
36
	}
37
38
39
	/**
40
	 * Renders the output based on the given template file name and the key/value pairs
41
	 *
42
	 * @param \Aimeos\Base\View\Iface $view View object
43
	 * @param string $filename File name of the view template
44
	 * @param array $values Associative list of key/value pairs
45
	 * @return string Output generated by the template
46
	 * @throws \Aimeos\Base\View\Exception If the template isn't found
47
	 */
48
	public function render( \Aimeos\Base\View\Iface $view, string $filename, array $values ) : string
49
	{
50
		$fluid = $this->objectManager->get( 'TYPO3\\CMS\\Fluid\\View\\StandaloneView' );
51
		$fluid->setPartialRootPaths( (array) $this->configuration['view']['partialRootPaths'] );
52
		$fluid->setLayoutRootPaths( (array) $this->configuration['view']['layoutRootPaths'] );
53
		$fluid->setTemplatePathAndFilename( $filename );
54
		$fluid->assign( '_aimeos_view', $view );
55
		$fluid->assignMultiple( $values );
56
57
		return $fluid->render();
58
	}
59
}
60