-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack-manifest.php
64 lines (57 loc) · 1.28 KB
/
webpack-manifest.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Grav\Plugin;
use Composer\Autoload\ClassLoader;
use Grav\Common\Plugin;
use Grav\Common\Twig\Twig;
use Grav\Plugin\WebpackManifest\WebpackManifestTwigExtension;
/**
* Webpack Manifest plugin class.
*
* @author Maarten de Boer <[email protected]>
* @license MIT
*/
class WebpackManifestPlugin extends Plugin
{
/**
* @inheritDoc
*/
public static function getSubscribedEvents()
{
return [
'onPluginsInitialized' => [
['onPluginsInitialized', 0],
['autoload', 100000]
]
];
}
/**
* Composer autoload.
*
* @return ClassLoader
*/
public function autoload()
{
return require __DIR__ . '/vendor/autoload.php';
}
/**
* Initialize the plugin.
*/
public function onPluginsInitialized()
{
if ($this->isAdmin() || $this->config["plugins.{$this->name}.enabled"] !== true) {
return;
}
$this->enable(
[
'onTwigExtensions' => ['onTwigExtensions', 0]
]
);
}
/**
* Initialise twig extension.
*/
public function onTwigExtensions()
{
$this->grav['twig']->twig->addExtension(new WebpackManifestTwigExtension());
}
}