Refactor Blade implementation. Use Container

This commit is contained in:
QWp6t
2016-12-06 03:28:41 -08:00
parent c69431efa5
commit 0d83ed4b8b
14 changed files with 250 additions and 257 deletions

View File

@@ -10,26 +10,32 @@ namespace Roots\Sage\Assets;
class JsonManifest implements ManifestInterface
{
/** @var array */
protected $manifest = [];
public $manifest;
/** @var string */
public $dist;
/**
* JsonManifest constructor
*
* @param string $manifestPath Local filesystem path to JSON-encoded manifest
* @param string $distUri Remote URI to assets root
*/
public function __construct($manifestPath)
public function __construct($manifestPath, $distUri)
{
$this->manifest = file_exists($manifestPath) ? json_decode(file_get_contents($manifestPath), true) : [];
$this->dist = $distUri;
}
/** @inheritdoc */
public function get($file)
public function get($asset)
{
return isset($this->manifest[$file]) ? $this->manifest[$file] : $file;
return isset($this->manifest[$asset]) ? $this->manifest[$asset] : $asset;
}
/** @inheritdoc */
public function getAll()
public function getUri($asset)
{
return $this->manifest;
return "{$this->dist}/{$this->get($asset)}";
}
}

View File

@@ -12,17 +12,20 @@ interface ManifestInterface
/**
* Get the cache-busted filename
*
* If the manifest does not have an entry for $file, then return $file
* If the manifest does not have an entry for $asset, then return $asset
*
* @param string $file The original name of the file before cache-busting
* @param string $asset The original name of the file before cache-busting
* @return string
*/
public function get($file);
public function get($asset);
/**
* Get the asset manifest
* Get the cache-busted URI
*
* @return array
* If the manifest does not have an entry for $asset, then return URI for $asset
*
* @param string $asset The original name of the file before cache-busting
* @return string
*/
public function getAll();
public function getUri($asset);
}