-
Notifications
You must be signed in to change notification settings - Fork 7
/
boot.php
47 lines (40 loc) · 1.51 KB
/
boot.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
<?php
/**
* This file is part of the Cheatsheet package.
*
* @author (c) Thomas Blum <thomas@addoff.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$addon = rex_addon::get('cheatsheet');
if (rex::isBackend() && is_object(rex::getUser())) {
rex_extension::register('PAGES_PREPARED', function () use ($addon) {
$providers = $addon->getProperty('providers', []);
foreach (\rex_package::getAvailablePackages() as $package) {
if ($package->hasProperty('cheatsheet')) {
$property = $package->getProperty('cheatsheet');
if (!is_array($property)) {
$property = [$property];
}
$providers = array_merge($providers, $property);
}
}
$page = \rex_be_controller::getPageObject('cheatsheet');
foreach ($providers as $provider) {
$instance = new $provider();
if (is_dir($instance->i18n())) {
\rex_i18n::addDirectory($instance->i18n());
}
$page->addSubpage($instance->page());
}
});
$stylesheets = $addon->getProperty('stylesheets', []);
foreach ($stylesheets as $stylesheet) {
rex_view::addCssFile($addon->getAssetsUrl($stylesheet));
}
$javascripts = $addon->getProperty('javascripts', []);
foreach ($javascripts as $javascript) {
rex_view::addJsFile($addon->getAssetsUrl($javascript));
}
}