<?php

/**
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
 * @copyright Aimeos (aimeos.org), 2017-2025
 * @package MW
 * @subpackage View
 */


namespace Aimeos\Base\View\Engine;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;


/**
 * TYPO3 view engine implementation
 *
 * @package MW
 * @subpackage View
 */
class Typo3 implements Iface
{
	private $view;


	/**
	 * Initializes the view object
	 *
	 * @param \TYPO3Fluid\Fluid\View\ViewInterface $view TYPO3 view
	 */
	public function __construct( \TYPO3Fluid\Fluid\View\ViewInterface $view )
	{
		$this->view = $view;
	}


	/**
	 * Renders the output based on the given template file name and the key/value pairs
	 *
	 * @param \Aimeos\Base\View\Iface $view View object
	 * @param string $filename File name of the view template
	 * @param array $values Associative list of key/value pairs
	 * @return string Output generated by the template
	 * @throws \Aimeos\Base\View\Exception If the template isn't found
	 */
	public function render( \Aimeos\Base\View\Iface $view, string $filename, array $values ) : string
	{
		$fluid = clone $this->view;
		$fluid->setTemplatePathAndFilename( $filename );
		$fluid->assign( '_aimeos_view', $view );
		$fluid->assignMultiple( $values );

		return $fluid->render();
	}
}
