-
Notifications
You must be signed in to change notification settings - Fork 0
/
meta-as-json.php
41 lines (36 loc) · 1.05 KB
/
meta-as-json.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
<?php
namespace Grav\Plugin;
use Grav\Common\Plugin;
class metaAsJsonPlugin extends Plugin
{
/**
* Subscribe to required events
*
* @return array
*/
public static function getSubscribedEvents()
{
return [
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onGetPageTemplates' => ['onGetPageTemplates', 0]
];
}
/**
* Add current directory to twig lookup paths.
*/
public function onTwigTemplatePaths()
{
// Don't proceed if we are in the admin
if ($this->isAdmin()) {
return;
}
array_unshift($this->grav['twig']->twig_paths, __DIR__ . '/templates');
}
public function onGetPageTemplates($event)
{
$types = $event->types;
$locator = $this->grav['locator'];
$types->scanBlueprints($locator->findResource('plugin://' . $this->name . '/blueprints'));
$types->scanTemplates($locator->findResource('plugin://' . $this->name . '/templates'));
}
}