-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin-customize.php
79 lines (69 loc) · 1.95 KB
/
admin-customize.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Grav\Plugin;
use Grav\Common\Grav;
use Grav\Common\Plugin;
use Grav\Common\Page\Page;
use RocketTheme\Toolbox\Event\Event;
class AdminCustomizePlugin extends Plugin
{
/**
* Initialize plugin and subsequent events
* @return array
*/
public static function getSubscribedEvents()
{
return [
'onPluginsInitialized' => ['onPluginsInitialized', 0],
'onGetPageBlueprints' => ['onGetPageBlueprints', 0],
'onGetPageTemplates' => ['onGetPageTemplates', 0],
];
}
/**
* Register events with Grav
* @return void
*/
public function onPluginsInitialized()
{
/* Check if Admin-interface */
if (!$this->isAdmin()) {
return;
}
require_once __DIR__ . '/vendor/autoload.php';
$this->enable([
'onAdminTwigTemplatePaths' => ['onAdminTwigTemplatePaths', 0]
]);
}
/**
* Register template overrides
* @param RocketTheme\Toolbox\Event\Event $event
* @return void
*/
public function onAdminTwigTemplatePaths($event)
{
$event['paths'] = array_merge($event['paths'], [__DIR__ . '/admin/themes/grav/templates']);
$event['paths'] = array_merge($event['paths'], Grav::instance()['locator']->findResources('user://templates/pages'));
//$this->grav['twig']->twig_paths[] = __DIR__ . '/admin/themes/grav/templates';
}
/**
* Add page blueprints
*
* @param Event $event
*/
public function onGetPageBlueprints(Event $event)
{
/** @var Types $types */
$types = $event->types;
$types->scanBlueprints('user://blueprints/pages/');
}
/**
* Add page template types.
*
* @param Event $event
*/
public function onGetPageTemplates(Event $event)
{
/** @var Types $types */
$types = $event->types;
$types->scanTemplates('user://templates/pages/');
}
}