<?php

namespace Uhura\Grossmarkt\ViewHelpers;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

class ConverteSvgViewHelper extends AbstractViewHelper
{
    protected $escapeOutput = false;

    public function initializeArguments(): void
    {
        $this->registerArgument('path', 'string', 'SVG path', true);
    }

    public function render(): string
    {
        $path = $this->arguments['path'];
        $absolutePath = GeneralUtility::getFileAbsFileName($path);

        if (!$absolutePath || !is_file($absolutePath)) {
            return '';
        }

        return file_get_contents($absolutePath);
    }
}