FestinHegre/vendor/symfony/asset-mapper/MapperAwareAssetPackage.php
2024-09-26 17:26:04 +02:00

44 lines
1.1 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\AssetMapper;
use Symfony\Component\Asset\PackageInterface;
/**
* Decorates asset packages to support resolving assets from the asset mapper.
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
final class MapperAwareAssetPackage implements PackageInterface
{
public function __construct(
private readonly PackageInterface $innerPackage,
private readonly AssetMapperInterface $assetMapper,
) {
}
public function getVersion(string $path): string
{
return $this->innerPackage->getVersion($path);
}
public function getUrl(string $path): string
{
$publicPath = $this->assetMapper->getPublicPath($path);
if ($publicPath) {
$path = ltrim($publicPath, '/');
}
return $this->innerPackage->getUrl($path);
}
}