56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* This file is developed by evoWeb.
|
|
*
|
|
* It is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU General Public License, either version 2
|
|
* of the License, or any later version.
|
|
*
|
|
* For the full copyright and license information, please read the
|
|
* LICENSE.txt file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Evoweb\EwBase\ViewHelpers;
|
|
|
|
use TYPO3\CMS\Core\Resource\Exception\InvalidFileException;
|
|
use TYPO3\CMS\Core\Utility\PathUtility;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
|
|
|
/**
|
|
* = Examples =
|
|
*
|
|
* <code title="Simple Loop">
|
|
* <ewb:publicPath path="{data}">....</ewb:publicPath>
|
|
* </code>
|
|
* <output>
|
|
* fixed flexform data for extbase controller
|
|
* </output>
|
|
*
|
|
* @api
|
|
*/
|
|
class PublicPathViewHelper extends AbstractViewHelper
|
|
{
|
|
/**
|
|
* @var boolean
|
|
*/
|
|
protected $escapeOutput = false;
|
|
|
|
public function initializeArguments(): void
|
|
{
|
|
parent::initializeArguments();
|
|
$this->registerArgument('path', 'string', 'Extension resource path', true);
|
|
}
|
|
|
|
/**
|
|
* @throws InvalidFileException
|
|
*/
|
|
public function renderStatic(): string
|
|
{
|
|
$path = (string)$this->arguments['path'];
|
|
return PathUtility::getPublicResourceWebPath($path);
|
|
}
|
|
}
|