ew_base/Classes/User/AssetPath.php
2025-11-27 21:09:43 +01:00

48 lines
1.5 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\User;
use TYPO3\CMS\Core\SystemResource\Exception\CanNotResolvePublicResourceException;
use TYPO3\CMS\Core\SystemResource\Exception\CanNotResolveSystemResourceException;
use TYPO3\CMS\Core\SystemResource\Publishing\UriGenerationOptions;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* EXAMPLE:
* page.headerData.10 = USER
* page.headerData.10.userFunc = Evoweb\EwBase\User\AssetPath->getAbsolutePublicPath
* page.headerData.10.file = EXT:site_package/Resources/Public/manifest.json
* page.headerData.10.stdWrap.wrap = <link rel="manifest" href="|"/>
*/
class AssetPath
{
/**
* @throws CanNotResolvePublicResourceException
* @throws CanNotResolveSystemResourceException
*/
public function getAbsolutePublicPath(string $content, array $conf): string
{
return $content
. GeneralUtility::getIndpEnv('TYPO3_SITE_URL')
. ltrim((string)PathUtility::getSystemResourceUri(
$conf['file'],
null,
new UriGenerationOptions(cacheBusting: false)
), '/');
}
}