-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpi.mix.php
More file actions
30 lines (24 loc) · 801 Bytes
/
pi.mix.php
File metadata and controls
30 lines (24 loc) · 801 Bytes
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
<?php
class Mix
{
/**
* The data to return
*
* @var string
*/
public $return_data = '';
/**
* Plugin constructor
*/
public function __construct() {
$path = ee()->TMPL->fetch_param('path');
$baseUrl = ee('Config')->get('base_url');
$mixManifestPath = ee('Config')->get('mix_manifest');
if (empty($path)) throw new Exception('Mix: The "path" property is required.', 1);
if (! file_exists($mixManifestPath)) throw new Exception('Mix: Manifest file is required.', 2);
if (! isset(json_decode(file_get_contents($mixManifestPath), true)[$path])) throw new Exception("Mix: \"$path\" doesn't exists.", 3);
$asset = json_decode(file_get_contents($mixManifestPath), true)[$path];
$this->return_data = join('', [$baseUrl, $asset]);
}
}
// EOF