+ component & twig function/filter for inject assets from manifest.json

This commit is contained in:
2022-01-09 19:09:18 +03:00
parent ae36a5cb0a
commit 829231a79f
8 changed files with 149 additions and 6 deletions

View File

@ -4,12 +4,24 @@ class ManifestReader
{
private $manifest = null;
/**
* @param string $manifestPath
* @throws AssetsManifestException
*/
public function __construct(string $manifestPath)
{
if (!file_exists($manifestPath)) {
throw new AssetsManifestException('Not found: ' . $manifestPath);
}
if (!is_readable($manifestPath)) {
throw new AssetsManifestException('Not readable: ' . $manifestPath);
}
$this->manifest = json_decode(file_get_contents($manifestPath));
}
public function get($assetName)
public function get(string $assetName)
{
return $this->manifest->$assetName;
}