]> BookStack Code Mirror - bookstack/blob - app/helpers.php
Added page HTML export
[bookstack] / app / helpers.php
1 <?php
2
3 if (! function_exists('versioned_asset')) {
4     /**
5      * Get the path to a versioned file.
6      *
7      * @param  string  $file
8      * @return string
9      *
10      * @throws \InvalidArgumentException
11      */
12     function versioned_asset($file)
13     {
14         static $manifest = null;
15
16         if (is_null($manifest)) {
17             $manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true);
18         }
19
20         if (isset($manifest[$file])) {
21             return '/' . $manifest[$file];
22         }
23
24         if (file_exists(public_path($file))) {
25             return '/' . $file;
26         }
27
28         throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
29     }
30 }