-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlugin.php
More file actions
91 lines (80 loc) · 2.61 KB
/
Plugin.php
File metadata and controls
91 lines (80 loc) · 2.61 KB
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
<?php namespace OnePilot\Client;
use Event;
use Illuminate\Console\Scheduling\Schedule;
use OnePilot\Client\Classes\ComposerPackageDetector;
use OnePilot\Client\Classes\ComposerUpdateScheduler;
use OnePilot\Client\Contracts\PackageDetector;
use OnePilot\Client\Exceptions\Handler;
use OnePilot\Client\Models\Settings;
use System\Classes\PluginBase;
use System\Classes\SettingsManager;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
'name' => '1Pilot Client',
'description' => 'Central dashboard to manage your OctoberCMS websites',
'author' => '1Pilot.io',
'icon' => 'icon-plug',
'homepage' => 'https://1pilot.io',
];
}
public function registerSettings()
{
return [
'settings' => [
'label' => '1Pilot Settings',
'description' => 'Central dashboard to manage your OctoberCMS websites',
'category' => SettingsManager::CATEGORY_SYSTEM,
'icon' => 'icon-plug',
'class' => Settings::class,
'order' => 500,
'keywords' => '1Pilot 1Pilot.io OnePilot Dashboard',
'permissions' => ['OnePilot.client.access_settings'],
],
];
}
/**
* @param Schedule $schedule
*/
public function registerSchedule($schedule)
{
$schedule->call(function () {
Settings::instance()->logCronExecution();
})->everyFiveMinutes();
}
public function registerPermissions()
{
return [
'OnePilot.client.access_settings' => [
'label' => 'Access to 1Pilot settings',
'tab' => '1Pilot',
],
];
}
public function register()
{
$this->registerConsoleCommand('OnePilot.RunComposerUpdate', Console\RunComposerUpdate::class);
$this->app->bind(PackageDetector::class, function ($app) {
return new ComposerPackageDetector(base_path());
});
}
public function boot()
{
Handler::register();
$this->registerRunComposerUpdateSchedule();
}
private function registerRunComposerUpdateSchedule()
{
if (!class_exists('System')) {
return; // Only for OCv2
}
// Register schedule at the end to no impact website schedules
Event::listen('console.schedule', function ($schedule) {
$schedule->command(Console\RunComposerUpdate::class)
->when(ComposerUpdateScheduler::hasTask())
->withoutOverlapping();
});
}
}