|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Application as IlluminateApplication; |
|
6
|
|
|
use InvalidArgumentException; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Extends \Illuminate\Foundation\Application to override some defaults. |
|
10
|
|
|
*/ |
|
11
|
|
|
class Application extends IlluminateApplication |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Current Koel version. Must start with a v, and is synced with git tags/releases. |
|
15
|
|
|
* |
|
16
|
|
|
* @link https://github.com/phanan/koel/releases |
|
17
|
|
|
*/ |
|
18
|
|
|
public const KOEL_VERSION = 'v3.8.0'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* We have merged public path and base path. |
|
22
|
|
|
* |
|
23
|
|
|
* @return string |
|
24
|
|
|
*/ |
|
25
|
|
|
public function publicPath() |
|
26
|
|
|
{ |
|
27
|
|
|
return $this->basePath; |
|
28
|
|
|
} |
|
29
|
120 |
|
|
|
30
|
|
|
/** |
|
31
|
120 |
|
* Loads a revision'ed asset file, making use of gulp-rev |
|
32
|
|
|
* This is a copycat of L5's Elixir, but catered to our directory structure. |
|
33
|
|
|
* |
|
34
|
|
|
* @throws InvalidArgumentException |
|
35
|
|
|
*/ |
|
36
|
|
|
public function rev(string $file, string $manifestFile = null): string |
|
37
|
|
|
{ |
|
38
|
|
|
static $manifest = null; |
|
39
|
|
|
|
|
40
|
|
|
$manifestFile = $manifestFile ?: public_path('public/mix-manifest.json'); |
|
41
|
|
|
|
|
42
|
|
|
if ($manifest === null) { |
|
43
|
|
|
$manifest = json_decode(file_get_contents($manifestFile), true); |
|
44
|
|
|
} |
|
45
|
2 |
|
|
|
46
|
|
|
if (isset($manifest[$file])) { |
|
47
|
2 |
|
return file_exists(public_path('public/hot')) |
|
48
|
|
|
? "http://localhost:8080{$manifest[$file]}" |
|
49
|
2 |
|
: $this->staticUrl("public{$manifest[$file]}"); |
|
50
|
|
|
} |
|
51
|
2 |
|
|
|
52
|
1 |
|
throw new InvalidArgumentException("File {$file} not defined in asset manifest."); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
2 |
|
/** |
|
56
|
2 |
|
* Get a URL for static file requests. |
|
57
|
|
|
* If this installation of Koel has a CDN_URL configured, use it as the base. |
|
58
|
2 |
|
* Otherwise, just use a full URL to the asset. |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $name The additional resource name/path. |
|
61
|
|
|
*/ |
|
62
|
|
|
public function staticUrl(?string $name = null): string |
|
63
|
|
|
{ |
|
64
|
|
|
$cdnUrl = trim(config('koel.cdn.url'), '/ '); |
|
65
|
|
|
|
|
66
|
|
|
return $cdnUrl ? $cdnUrl.'/'.trim(ltrim($name, '/')) : trim(asset($name)); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|