Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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\AssetMapper\Factory\MappedAssetFactoryInterface;
/**
* Finds and returns assets in the pipeline.
*
* @final
*/
class AssetMapper implements AssetMapperInterface
{
public const MANIFEST_FILE_NAME = 'manifest.json';
private ?array $manifestData = null;
public function __construct(
private readonly AssetMapperRepository $mapperRepository,
private readonly MappedAssetFactoryInterface $mappedAssetFactory,
private readonly CompiledAssetMapperConfigReader $compiledConfigReader,
) {
}
public function getAsset(string $logicalPath): ?MappedAsset
{
$filePath = $this->mapperRepository->find($logicalPath);
if (null === $filePath) {
return null;
}
return $this->mappedAssetFactory->createMappedAsset($logicalPath, $filePath);
}
public function allAssets(): iterable
{
foreach ($this->mapperRepository->all() as $logicalPath => $filePath) {
$asset = $this->getAsset($logicalPath);
if (null === $asset) {
throw new \LogicException(sprintf('Asset "%s" could not be found.', $logicalPath));
}
yield $asset;
}
}
public function getAssetFromSourcePath(string $sourcePath): ?MappedAsset
{
$logicalPath = $this->mapperRepository->findLogicalPath($sourcePath);
if (null === $logicalPath) {
return null;
}
return $this->getAsset($logicalPath);
}
public function getPublicPath(string $logicalPath): ?string
{
$manifestData = $this->loadManifest();
if (isset($manifestData[$logicalPath])) {
return $manifestData[$logicalPath];
}
$asset = $this->getAsset($logicalPath);
return $asset?->publicPath;
}
private function loadManifest(): array
{
if (null === $this->manifestData) {
if (!$this->compiledConfigReader->configExists(self::MANIFEST_FILE_NAME)) {
$this->manifestData = [];
} else {
$this->manifestData = $this->compiledConfigReader->loadConfig(self::MANIFEST_FILE_NAME);
}
}
return $this->manifestData;
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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\AssetMapper\Factory\MappedAssetFactoryInterface;
/**
* Finds and returns assets in the pipeline.
*
* @final
*/
class AssetMapper implements AssetMapperInterface
{
public const MANIFEST_FILE_NAME = 'manifest.json';
private ?array $manifestData = null;
public function __construct(
private readonly AssetMapperRepository $mapperRepository,
private readonly MappedAssetFactoryInterface $mappedAssetFactory,
private readonly CompiledAssetMapperConfigReader $compiledConfigReader,
) {
}
public function getAsset(string $logicalPath): ?MappedAsset
{
$filePath = $this->mapperRepository->find($logicalPath);
if (null === $filePath) {
return null;
}
return $this->mappedAssetFactory->createMappedAsset($logicalPath, $filePath);
}
public function allAssets(): iterable
{
foreach ($this->mapperRepository->all() as $logicalPath => $filePath) {
$asset = $this->getAsset($logicalPath);
if (null === $asset) {
throw new \LogicException(sprintf('Asset "%s" could not be found.', $logicalPath));
}
yield $asset;
}
}
public function getAssetFromSourcePath(string $sourcePath): ?MappedAsset
{
$logicalPath = $this->mapperRepository->findLogicalPath($sourcePath);
if (null === $logicalPath) {
return null;
}
return $this->getAsset($logicalPath);
}
public function getPublicPath(string $logicalPath): ?string
{
$manifestData = $this->loadManifest();
if (isset($manifestData[$logicalPath])) {
return $manifestData[$logicalPath];
}
$asset = $this->getAsset($logicalPath);
return $asset?->publicPath;
}
private function loadManifest(): array
{
if (null === $this->manifestData) {
if (!$this->compiledConfigReader->configExists(self::MANIFEST_FILE_NAME)) {
$this->manifestData = [];
} else {
$this->manifestData = $this->compiledConfigReader->loadConfig(self::MANIFEST_FILE_NAME);
}
}
return $this->manifestData;
}
}
Function Calls
None |
Stats
MD5 | 45d6418d2590a8f7ad7a4828cd232a5f |
Eval Count | 0 |
Decode Time | 94 ms |