forked from panakour/oc-backup-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
94 lines (82 loc) · 2.62 KB
/
Plugin.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php namespace PanaKour\Backup;
use App;
use Backend;
use Config;
use Panakour\Backup\Models\Settings;
use System\Classes\PluginBase;
use Illuminate\Foundation\AliasLoader;
use System\Classes\SettingsManager;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
'name' => 'Backup',
'description' => 'Backup files and database of October CMS',
'author' => 'Panagiotis Koursaris',
'icon' => 'icon-floppy-o',
'homepage' => 'https://github.com/panakour/oc-backup-plugin',
];
}
public function registerNavigation()
{
return [
'backup' => [
'label' => 'Backup',
'url' => Backend::url('panakour/backup/backups'),
'icon' => 'icon-floppy-o',
'iconSvg' => 'plugins/panakour/backup/assets/images/backup-icon.svg',
'order' => 200,
'permissions' => ['panakour.backup.access'],
],
];
}
public function registerSettings()
{
return [
'config' => [
'label' => 'Backup',
'icon' => 'icon-floppy-o',
'description' => 'Configure the backup system.',
'category' => SettingsManager::CATEGORY_SYSTEM,
'class' => Settings::class,
'order' => 600,
'permissions' => ['panakour.backup.access'],
],
];
}
public function registerPermissions()
{
return [
'panakour.backup.access' => [
'label' => 'Manage backups',
'tab' => 'Backup'
],
];
}
public function boot()
{
$this->bootPackages();
}
public function bootPackages()
{
$pluginNamespace = str_replace('\\', '.', strtolower(__NAMESPACE__));
$aliasLoader = AliasLoader::getInstance();
$packages = Config::get($pluginNamespace.'::packages');
foreach ($packages as $name => $options) {
if (! empty($options['config']) && ! empty($options['config_namespace'])) {
Config::set($options['config_namespace'], $options['config']);
}
if (! empty($options['providers'])) {
foreach ($options['providers'] as $provider) {
App::register($provider);
}
}
if (! empty($options['aliases'])) {
foreach ($options['aliases'] as $alias => $path) {
$aliasLoader->alias($alias, $path);
}
}
}
}
}