1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace nystudio107\transcoder\variables; |
4
|
|
|
|
5
|
|
|
use nystudio107\transcoder\helpers\Manifest as ManifestHelper; |
6
|
|
|
use nystudio107\transcoder\assetbundles\transcoder\TranscoderAsset; |
7
|
|
|
|
8
|
|
|
use Craft; |
9
|
|
|
use craft\helpers\Template; |
10
|
|
|
|
11
|
|
|
use yii\base\InvalidConfigException; |
12
|
|
|
use yii\web\NotFoundHttpException; |
13
|
|
|
|
14
|
|
|
use Twig\Markup; |
15
|
|
|
|
16
|
|
|
class ManifestVariable |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
// Public Methods |
19
|
|
|
// ========================================================================= |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Get the passed in JS modules from the manifest, and register them in the current Craft view |
23
|
|
|
* |
24
|
|
|
* @param array $modules |
|
|
|
|
25
|
|
|
* @throws InvalidConfigException |
|
|
|
|
26
|
|
|
* @throws NotFoundHttpException |
|
|
|
|
27
|
|
|
*/ |
|
|
|
|
28
|
|
|
public function registerJsModules(array $modules) |
29
|
|
|
{ |
30
|
|
|
ManifestHelper::registerJsModules($modules); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get the passed in CS modules from the manifest, and register them in the current Craft view |
35
|
|
|
* |
36
|
|
|
* @param array $modules |
|
|
|
|
37
|
|
|
* @throws InvalidConfigException |
|
|
|
|
38
|
|
|
* @throws NotFoundHttpException |
|
|
|
|
39
|
|
|
*/ |
|
|
|
|
40
|
|
|
public function registerCssModules(array $modules) |
41
|
|
|
{ |
42
|
|
|
ManifestHelper::registerCssModules($modules); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Get the passed in JS module from the manifest, then output a `<script src="">` tag for it in the HTML |
47
|
|
|
* |
48
|
|
|
* @param string $moduleName |
|
|
|
|
49
|
|
|
* @param bool $async |
|
|
|
|
50
|
|
|
* |
51
|
|
|
* @return null|Markup |
52
|
|
|
* @throws NotFoundHttpException |
53
|
|
|
*/ |
54
|
|
|
public function includeJsModule(string $moduleName, bool $async = false) |
55
|
|
|
{ |
56
|
|
|
return Template::raw( |
57
|
|
|
ManifestHelper::includeJsModule($moduleName, $async) ?? '' |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the passed in CS module from the manifest, then output a `<link>` tag for it in the HTML |
63
|
|
|
* |
64
|
|
|
* @param string $moduleName |
|
|
|
|
65
|
|
|
* @param bool $async |
|
|
|
|
66
|
|
|
* |
67
|
|
|
* @return Markup |
68
|
|
|
* @throws NotFoundHttpException |
69
|
|
|
*/ |
70
|
|
|
public function includeCssModule(string $moduleName, bool $async = false): Markup |
71
|
|
|
{ |
72
|
|
|
return Template::raw( |
73
|
|
|
ManifestHelper::includeCssModule($moduleName, $async) ?? '' |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|