Restructure theme, use autoloader
This commit is contained in:
26
app/lib/Sage/Assets/IManifest.php
Normal file
26
app/lib/Sage/Assets/IManifest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php namespace Roots\Sage\Assets;
|
||||
|
||||
/**
|
||||
* Interface IManifest
|
||||
* @package Roots\Sage
|
||||
* @author QWp6t
|
||||
*/
|
||||
interface IManifest {
|
||||
|
||||
/**
|
||||
* Get the cache-busted filename
|
||||
*
|
||||
* If the manifest does not have an entry for $file, then return $file
|
||||
*
|
||||
* @param string $file The original name of the file before cache-busting
|
||||
* @return string
|
||||
*/
|
||||
public function get($file);
|
||||
|
||||
/**
|
||||
* Get the asset manifest
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAll();
|
||||
}
|
||||
29
app/lib/Sage/Assets/JsonManifest.php
Normal file
29
app/lib/Sage/Assets/JsonManifest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php namespace Roots\Sage\Assets;
|
||||
|
||||
/**
|
||||
* Class JsonManifest
|
||||
* @package Roots\Sage
|
||||
* @author QWp6t
|
||||
*/
|
||||
class JsonManifest implements IManifest {
|
||||
/** @var array */
|
||||
protected $manifest = [];
|
||||
|
||||
/**
|
||||
* JsonManifest constructor
|
||||
* @param string $manifestPath Local filesystem path to JSON-encoded manifest
|
||||
*/
|
||||
public function __construct($manifestPath) {
|
||||
$this->manifest = file_exists($manifestPath) ? json_decode(file_get_contents($manifestPath), true) : [];
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function get($file) {
|
||||
return isset($this->manifest[$file]) ? $this->manifest[$file] : $file;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function getAll() {
|
||||
return $this->manifest;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user