+ component & twig function/filter for inject assets from manifest.json
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user