<?php
namespace Medienreaktor\Energize\ViewHelpers;

use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* @package Energize
* @subpackage ViewHelpers
*/
class ProductDataViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper {

    /**
     * @var bool
     */
    protected $escapeOutput = false;

    /**
     * productGroupRepository
     *
     * @var \Medienreaktor\Products\Service\ProductDataService
     */
    protected $productDataService = null;
    public function __construct(\Medienreaktor\Products\Service\ProductDataService $productDataService)
    {
        $this->productDataService = $productDataService;
    }

	/**
	* Arguments Initialization
	*/
	public function initializeArguments(): void {
		$this->registerArgument('as', 'string', 'The variable name in which the data should be saved', TRUE);
		$this->registerArgument('productGroupId', 'string', 'Id of the product group to load', TRUE);
	}

     /**
     * Render method
     * @return string
     */
    public function render() {

    	$as = $this->arguments['as'];


        $return = $this->productDataService->getProductDataByProductGroupId($this->arguments["productGroupId"]);


		$this->templateVariableContainer->add($as, $return);
		$output = $this->renderChildren();
		$this->templateVariableContainer->remove($as);
		return $output;
    }


}
