-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
63 lines (55 loc) · 3.01 KB
/
bootstrap.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
<?php
use Foolz\FoolFrame\Model\Autoloader;
use Foolz\FoolFrame\Model\Context;
use Foolz\Plugin\Event;
class HHVM_NASMediaPurge
{
public function run()
{
Event::forge('Foolz\Plugin\Plugin::execute#foolz/foolfuuka-plugin-nas-media-purge')
->setCall(function ($result) {
/* @var Context $context */
$context = $result->getParam('context');
/** @var Autoloader $autoloader */
$autoloader = $context->getService('autoloader');
$autoloader->addClassMap([
'Foolz\FoolFrame\Controller\Admin\Plugins\NASMediaPurge' => __DIR__ . '/classes/controller/admin.php',
'Foolz\FoolFuuka\Plugins\NASMediaPurge\Model\NASMediaPurge' => __DIR__ . '/classes/model/purge.php'
]);
$context->getContainer()
->register('foolfuuka-plugin.nas_media_purge', 'Foolz\FoolFuuka\Plugins\NASMediaPurge\Model\NASMediaPurge')
->addArgument($context);
Event::forge('Foolz\FoolFrame\Model\Context::handleWeb#obj.afterAuth')
->setCall(function ($result) use ($context) {
// don't add the admin panels if the user is not an admin
if ($context->getService('auth')->hasAccess('maccess.admin')) {
$context->getRouteCollection()->add(
'foolfuuka.plugin.nas_media_purge.admin', new \Symfony\Component\Routing\Route(
'/admin/plugins/nas_media_purge/{_suffix}',
[
'_suffix' => 'manage',
'_controller' => 'Foolz\FoolFrame\Controller\Admin\Plugins\NASMediaPurge::manage'
],
[
'_suffix' => '.*'
]
)
);
Event::forge('Foolz\FoolFrame\Controller\Admin::before#var.sidebar')
->setCall(function ($result) {
$sidebar = $result->getParam('sidebar');
$sidebar[]['plugins'] = [
'content' => ['nas_media_purge/manage' => ['level' => 'admin', 'name' => 'NAS Media Purge', 'icon' => 'icon-leaf']]
];
$result->setParam('sidebar', $sidebar);
});
}
});
Event::forge('Foolz\FoolFuuka\Model\Media::delete#call.beforeMethod')
->setCall(function ($result) use ($context) {
$context->getService('foolfuuka-plugin.nas_media_purge')->beforeDeleteMedia($result);
});
});
}
}
(new HHVM_NASMediaPurge())->run();