-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlugin.php
82 lines (69 loc) · 2.19 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
<?php
declare(strict_types=1);
namespace Vdlp\Telescope;
use Backend\Helpers\Backend;
use Illuminate\Auth\Access\Gate;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Application;
use System\Classes\PluginBase;
use Vdlp\Telescope\ServiceProviders\TelescopeServiceProvider;
final class Plugin extends PluginBase
{
private Backend $backend;
public function __construct(Application $app)
{
parent::__construct($app);
$this->backend = $app->make(Backend::class);
}
public function pluginDetails(): array
{
return [
'name' => 'Telescope',
'description' => 'Laravel Telescope integration for October CMS',
'author' => 'Van der Let & Partners',
'icon' => 'icon-area-chart',
'homepage' => 'https://octobercms.com/plugin/vdlp-telescope',
];
}
public function register(): void
{
if ($this->app->environment('local') === false) {
return;
}
$this->registerAccessGate();
$this->app->register(TelescopeServiceProvider::class);
}
public function registerPermissions(): array
{
return [
'vdlp.telescope.access_dashboard' => [
'tab' => 'Telescope',
'label' => 'Access to the Telescope dashboard',
'roles' => ['developer'],
],
];
}
public function registerNavigation(): array
{
return [
'dashboard' => [
'label' => 'Telescope',
'url' => $this->backend->url('vdlp/telescope/dashboard'),
'iconSvg' => '/plugins/vdlp/telescope/assets/icons/telescope.svg',
'permissions' => ['vdlp.telescope.access_dashboard'],
'order' => 510,
],
];
}
/**
* Register the access gate service.
*/
private function registerAccessGate(): void
{
$this->app->singleton(GateContract::class, static function ($app): GateContract {
return new Gate($app, static function () use ($app) {
return call_user_func($app['auth']->userResolver());
});
});
}
}