-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.php
More file actions
179 lines (158 loc) · 4.87 KB
/
Plugin.php
File metadata and controls
179 lines (158 loc) · 4.87 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php namespace LearnKit\H5p;
use App;
use Config;
use Backend;
use BackendAuth;
use System\Classes\PluginBase;
use Illuminate\Foundation\AliasLoader;
use LearnKit\H5p\Classes\H5pHelper;
/**
* H5p Plugin Information File
*/
class Plugin extends PluginBase
{
public $require = [
'RainLab.User',
];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'H5p',
'description' => 'No description provided yet...',
'author' => 'LearnKit',
'icon' => 'icon-leaf'
];
}
/**
* Register method, called when the plugin is first registered.
*
* @return void
*/
public function register()
{
}
/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{
$this->bootPackages();
$this->app->singleton('LaravelH5p', function ($app) {
$LaravelH5p = new \LearnKit\H5p\Classes\OctoberH5p($app);
return $LaravelH5p;
});
$this->app->singleton('OctoberH5p', function ($app) {
$LaravelH5p = new \LearnKit\H5p\Classes\OctoberH5p($app);
return $LaravelH5p;
});
$this->app->bind('H5pHelper', function () {
return new H5pHelper();
});
if (App::runningInBackend()) {
$this->app->bind('Illuminate\Contracts\Auth\Factory', function () {
return BackendAuth::instance();
});
}
}
/**
* Registers any front-end components implemented in this plugin.
*
* @return array
*/
public function registerComponents()
{
return [
'LearnKit\H5p\Components\H5pEmbed' => 'h5p',
];
}
/**
* Registers any back-end permissions used by this plugin.
*
* @return array
*/
public function registerPermissions()
{
return [
'learnkit.h5p.manage_content' => [
'tab' => 'H5P',
'label' => 'Manage H5P content'
],
];
}
/**
* Registers back-end navigation items for this plugin.
*
* @return array
*/
public function registerNavigation()
{
return [
'h5p' => [
'label' => 'H5P',
'url' => Backend::url('learnkit/h5p/dashboard'),
'iconSvg' => '/plugins/learnkit/h5p/assets/h5p.svg',
'permissions' => ['learnkit.h5p.*'],
'order' => 500,
'sideMenu' => [
'contents' => [
'label' => 'Contents',
'url' => Backend::url('/learnkit/h5p/contents'),
'icon' => 'icon-list',
],
'libraries' => [
'label' => 'Libraries',
'url' => Backend::url('/learnkit/h5p/libraries'),
'icon' => 'icon-upload',
],
],
],
];
}
public function registerFormWidgets()
{
return [
'LearnKit\H5p\FormWidgets\H5pEditor' => 'h5peditor',
];
}
/**
* Boots (configures and registers) any packages found within this plugin's packages.load configuration value
*
* @see https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-plugins
* @author Luke Towers <octobercms@luketowers.ca>
*/
public function bootPackages()
{
// Get the namespace of the current plugin to use in accessing the Config of the plugin
$pluginNamespace = str_replace('\\', '.', strtolower(__NAMESPACE__));
// Instantiate the AliasLoader for any aliases that will be loaded
$aliasLoader = AliasLoader::getInstance();
// Get the packages to boot
$packages = Config::get($pluginNamespace . '::packages');
// Boot each package
foreach ($packages as $name => $options) {
// Setup the configuration for the package, pulling from this plugin's config
if (!empty($options['config']) && !empty($options['config_namespace'])) {
Config::set($options['config_namespace'], $options['config']);
}
// Register any Service Providers for the package
if (!empty($options['providers'])) {
foreach ($options['providers'] as $provider) {
App::register($provider);
}
}
// Register any Aliases for the package
if (!empty($options['aliases'])) {
foreach ($options['aliases'] as $alias => $path) {
$aliasLoader->alias($alias, $path);
}
}
}
}
}