-
Notifications
You must be signed in to change notification settings - Fork 1
/
Plugin.php
50 lines (44 loc) · 1.29 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php namespace Rebel59\MixManifest;
use Backend;
use Config;
use Cms\Classes\Theme;
use System\Classes\PluginBase;
/**
* MixManifest Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'Mix Manifest',
'description' => 'Provides twig function to read the manifest file generated by Laravel Mix Versioning',
'author' => 'Rebel59',
'homepage' => 'https://rebel59.nl',
'icon' => 'icon-leaf'
];
}
public function registerMarkupTags()
{
return [
'functions' => [
'getVersionedCss' => [$this, 'readManifest'], // @Deprecated
'mix' => [$this, 'readManifest']
]
];
}
public function readManifest($path, $prefix = '/assets')
{
$loc = env('MANIFEST_PATH');
$manifest = file_get_contents($loc);
$manifest = json_decode($manifest);
$themeCode = Theme::getActiveThemeCode();
$themePath = Config::get('app.url') . Config::get('cms.themesPath') . "/" . $themeCode;
return $themePath . $prefix . $manifest->$path;
}
}