|
1
|
|
|
<?php namespace Bedard\Shop; |
|
2
|
|
|
|
|
3
|
|
|
use Backend; |
|
4
|
|
|
use System\Classes\PluginBase; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Shop Plugin Information File. |
|
8
|
|
|
*/ |
|
9
|
|
|
class Plugin extends PluginBase |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var array Plugin dependencies |
|
13
|
|
|
*/ |
|
14
|
|
|
public $require = [ |
|
15
|
|
|
'RainLab.User', |
|
16
|
|
|
]; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Returns information about this plugin. |
|
20
|
|
|
* |
|
21
|
|
|
* @return array |
|
22
|
|
|
*/ |
|
23
|
|
|
public function pluginDetails() |
|
24
|
|
|
{ |
|
25
|
|
|
return [ |
|
26
|
|
|
'name' => 'bedard.shop::lang.plugin.name', |
|
27
|
|
|
'description' => 'bedard.shop::lang.plugin.description', |
|
28
|
|
|
'author' => 'Bedard', |
|
29
|
|
|
'icon' => 'icon-shopping-cart', |
|
30
|
|
|
]; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Boot method, called right before the request route. |
|
35
|
|
|
* |
|
36
|
|
|
* @return array |
|
37
|
|
|
*/ |
|
38
|
|
|
public function boot() |
|
39
|
|
|
{ |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Register method, called when the plugin is first registered. |
|
44
|
|
|
* |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
public function register() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->registerConsoleCommand('shop.abandon', 'Bedard\Shop\Console\Abandon'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Registers any front-end components implemented in this plugin. |
|
54
|
|
|
* |
|
55
|
|
|
* @return array |
|
56
|
|
|
*/ |
|
57
|
|
|
public function registerComponents() |
|
58
|
|
|
{ |
|
59
|
|
|
return []; // Remove this line to activate |
|
60
|
|
|
|
|
61
|
|
|
return [ |
|
|
|
|
|
|
62
|
|
|
'Bedard\Shop\Components\MyComponent' => 'myComponent', |
|
63
|
|
|
]; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Registers back-end navigation items for this plugin. |
|
68
|
|
|
* |
|
69
|
|
|
* @return array |
|
70
|
|
|
*/ |
|
71
|
|
|
public function registerNavigation() |
|
72
|
|
|
{ |
|
73
|
|
|
return [ |
|
74
|
|
|
'shop' => [ |
|
75
|
|
|
'icon' => 'icon-shopping-cart', |
|
76
|
|
|
'label' => 'bedard.shop::lang.plugin.name', |
|
77
|
|
|
'order' => 500, |
|
78
|
|
|
'permissions' => ['bedard.shop.*'], |
|
79
|
|
|
'url' => Backend::url('bedard/shop/carts'), |
|
80
|
|
|
'sideMenu' => [ |
|
81
|
|
|
'carts' => [ |
|
82
|
|
|
'icon' => 'icon-shopping-cart', |
|
83
|
|
|
'label' => 'bedard.shop::lang.carts.plural', |
|
84
|
|
|
'permissions' => ['bedard.shop.carts.*'], |
|
85
|
|
|
'url' => Backend::url('bedard/shop/carts'), |
|
86
|
|
|
], |
|
87
|
|
|
'statuses' => [ |
|
88
|
|
|
'icon' => 'icon-tags', |
|
89
|
|
|
'label' => 'bedard.shop::lang.statuses.plural', |
|
90
|
|
|
'permissions' => ['bedard.shop.statuses.*'], |
|
91
|
|
|
'url' => Backend::url('bedard/shop/statuses'), |
|
92
|
|
|
], |
|
93
|
|
|
'products' => [ |
|
94
|
|
|
'icon' => 'icon-cubes', |
|
95
|
|
|
'label' => 'bedard.shop::lang.products.plural', |
|
96
|
|
|
'permissions' => ['bedard.shop.products.*'], |
|
97
|
|
|
'url' => Backend::url('bedard/shop/products'), |
|
98
|
|
|
], |
|
99
|
|
|
'categories' => [ |
|
100
|
|
|
'icon' => 'icon-folder-o', |
|
101
|
|
|
'label' => 'bedard.shop::lang.categories.plural', |
|
102
|
|
|
'permissions' => ['bedard.shop.categories.*'], |
|
103
|
|
|
'url' => Backend::url('bedard/shop/categories'), |
|
104
|
|
|
], |
|
105
|
|
|
'settings' => [ |
|
106
|
|
|
'icon' => 'icon-cog', |
|
107
|
|
|
'label' => 'bedard.shop::lang.settings.plural', |
|
108
|
|
|
'permissions' => ['bedard.shop.settings.*'], |
|
109
|
|
|
'url' => Backend::url('system/settings/update/bedard/shop/general'), |
|
110
|
|
|
], |
|
111
|
|
|
], |
|
112
|
|
|
], |
|
113
|
|
|
]; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Registers any back-end permissions used by this plugin. |
|
118
|
|
|
* |
|
119
|
|
|
* @return array |
|
120
|
|
|
*/ |
|
121
|
|
|
public function registerPermissions() |
|
122
|
|
|
{ |
|
123
|
|
|
return [ |
|
124
|
|
|
'bedard.shop.carts.manage' => [ |
|
125
|
|
|
'label' => 'bedard.shop::lang.plugin.permissions.carts', |
|
126
|
|
|
'tab' => 'bedard.shop::lang.plugin.name', |
|
127
|
|
|
], |
|
128
|
|
|
'bedard.shop.categories.manage' => [ |
|
129
|
|
|
'label' => 'bedard.shop::lang.plugin.permissions.categories', |
|
130
|
|
|
'tab' => 'bedard.shop::lang.plugin.name', |
|
131
|
|
|
], |
|
132
|
|
|
'bedard.shop.products.manage' => [ |
|
133
|
|
|
'label' => 'bedard.shop::lang.plugin.permissions.products', |
|
134
|
|
|
'tab' => 'bedard.shop::lang.plugin.name', |
|
135
|
|
|
], |
|
136
|
|
|
'bedard.shop.settings.manage' => [ |
|
137
|
|
|
'label' => 'bedard.shop::lang.plugin.permissions.settings', |
|
138
|
|
|
'tab' => 'bedard.shop::lang.plugin.name', |
|
139
|
|
|
], |
|
140
|
|
|
'bedard.shop.statuses.manage' => [ |
|
141
|
|
|
'label' => 'bedard.shop::lang.plugin.permissions.statuses', |
|
142
|
|
|
'tab' => 'bedard.shop::lang.plugin.name', |
|
143
|
|
|
], |
|
144
|
|
|
]; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* Register scheduled tasks. |
|
149
|
|
|
* |
|
150
|
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
151
|
|
|
* @return void |
|
152
|
|
|
*/ |
|
153
|
|
|
public function registerSchedule($schedule) |
|
154
|
|
|
{ |
|
155
|
|
|
$schedule->command('shop:abandon')->everyTenMinutes(); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Register settings models. |
|
160
|
|
|
* |
|
161
|
|
|
* @return array |
|
162
|
|
|
*/ |
|
163
|
|
|
public function registerSettings() |
|
164
|
|
|
{ |
|
165
|
|
|
return [ |
|
166
|
|
|
'general' => [ |
|
167
|
|
|
'category' => 'bedard.shop::lang.plugin.name', |
|
168
|
|
|
'class' => 'Bedard\Shop\Models\Settings', |
|
169
|
|
|
'description' => 'bedard.shop::lang.settings.title', |
|
170
|
|
|
'icon' => 'icon-cog', |
|
171
|
|
|
'label' => 'bedard.shop::lang.settings.label', |
|
172
|
|
|
'order' => 100, |
|
173
|
|
|
'permissions' => ['bedard.shop.settings.manage'], |
|
174
|
|
|
], |
|
175
|
|
|
'api' => [ |
|
176
|
|
|
'category' => 'bedard.shop::lang.plugin.name', |
|
177
|
|
|
'class' => 'Bedard\Shop\Models\ApiSettings', |
|
178
|
|
|
'description' => 'bedard.shop::lang.api.title', |
|
179
|
|
|
'icon' => 'icon-code', |
|
180
|
|
|
'label' => 'bedard.shop::lang.api.label', |
|
181
|
|
|
'order' => 200, |
|
182
|
|
|
'permissions' => ['bedard.shop.settings.manage'], |
|
183
|
|
|
], |
|
184
|
|
|
'payment' => [ |
|
185
|
|
|
'category' => 'bedard.shop::lang.plugin.name', |
|
186
|
|
|
'class' => 'Bedard\Shop\Models\PaymentDrivers', |
|
187
|
|
|
'description' => 'bedard.shop::lang.payment.title', |
|
188
|
|
|
'icon' => 'icon-money', |
|
189
|
|
|
'label' => 'bedard.shop::lang.payment.label', |
|
190
|
|
|
'order' => 300, |
|
191
|
|
|
'permissions' => ['bedard.shop.settings.manage'], |
|
192
|
|
|
], |
|
193
|
|
|
]; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* Register drivers. |
|
198
|
|
|
* |
|
199
|
|
|
* @return array |
|
200
|
|
|
*/ |
|
201
|
|
|
public function registerShopDrivers() |
|
202
|
|
|
{ |
|
203
|
|
|
return [ |
|
204
|
|
|
'nopayment' => [ |
|
205
|
|
|
'class' => 'Bedard\Shop\Drivers\NoPayment', |
|
206
|
|
|
'name' => 'bedard.shop::lang.drivers.nopayment.name', |
|
207
|
|
|
'thumbnail' => null, |
|
208
|
|
|
'type' => 'payment', |
|
209
|
|
|
], |
|
210
|
|
|
]; |
|
211
|
|
|
} |
|
212
|
|
|
} |
|
213
|
|
|
|
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return,dieorexitstatements that have been added for debug purposes.In the above example, the last
return falsewill never be executed, because a return statement has already been met in every possible execution path.