mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Foundation\Application as IlluminateApplication;
|
|
use InvalidArgumentException;
|
|
|
|
/**
|
|
* Extends \Illuminate\Foundation\Application to override some defaults.
|
|
*/
|
|
class Application extends IlluminateApplication
|
|
{
|
|
/**
|
|
* Current Koel version. Must start with a v, and is synced with git tags/releases.
|
|
*
|
|
* @see https://github.com/phanan/koel/releases
|
|
*/
|
|
public const KOEL_VERSION = 'v4.4.0';
|
|
|
|
/**
|
|
* Loads a revision'ed asset file, making use of gulp-rev
|
|
* This is a copycat of L5's Elixir, but catered to our directory structure.
|
|
*
|
|
* @throws InvalidArgumentException
|
|
*/
|
|
public function rev(string $file, string $manifestFile = null): string
|
|
{
|
|
static $manifest = null;
|
|
|
|
$manifestFile = $manifestFile ?: public_path('mix-manifest.json');
|
|
|
|
if ($manifest === null) {
|
|
$manifest = json_decode(file_get_contents($manifestFile), true);
|
|
}
|
|
|
|
if (isset($manifest[$file])) {
|
|
return file_exists(public_path('hot'))
|
|
? "http://localhost:8080{$manifest[$file]}"
|
|
: $this->staticUrl("{$manifest[$file]}");
|
|
}
|
|
|
|
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
|
|
}
|
|
|
|
/**
|
|
* Get a URL for static file requests.
|
|
* If this installation of Koel has a CDN_URL configured, use it as the base.
|
|
* Otherwise, just use a full URL to the asset.
|
|
*
|
|
* @param string $name the additional resource name/path
|
|
*/
|
|
public function staticUrl(?string $name = null): string
|
|
{
|
|
$cdnUrl = trim(config('koel.cdn.url'), '/ ');
|
|
|
|
return $cdnUrl ? $cdnUrl.'/'.trim(ltrim($name, '/')) : trim(asset($name));
|
|
}
|
|
}
|