-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstaller.php
41 lines (31 loc) · 1003 Bytes
/
Installer.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 Flute\Modules\News;
use Flute\Core\Database\Entities\Permission;
use Flute\Modules\News\Widgets\News\Widget;
class Installer extends \Flute\Core\Support\AbstractModuleInstaller
{
public function install(\Flute\Core\Modules\ModuleInformation &$module): bool
{
$permission = rep(Permission::class)->findOne([
'name' => 'admin.news'
]);
if (!$permission) {
$permission = new Permission;
$permission->name = 'admin.news';
$permission->desc = 'news.perm_desc';
transaction($permission)->run();
}
return true;
}
public function uninstall(\Flute\Core\Modules\ModuleInformation &$module): bool
{
$permission = rep(Permission::class)->findOne([
'name' => 'admin.news'
]);
if ($permission) {
transaction($permission, 'delete')->run();
}
widgets()->unregister(Widget::class);
return true;
}
}