-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Plugin.php
207 lines (197 loc) · 8.25 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php namespace Lovata\Shopaholic;
use Event;
use Backend;
use System\Classes\PluginBase;
//Console command
use Lovata\Shopaholic\Classes\Console\CheckTableIntegrity;
use Lovata\Shopaholic\Classes\Console\ImportFromXML;
use Lovata\Shopaholic\Classes\Console\PreconfigureImportSettingsFromXML;
//Event list
use Lovata\Shopaholic\Classes\Event\ExtendMenuHandler;
//Brand events
use Lovata\Shopaholic\Classes\Event\Brand\BrandModelHandler;
//Category events
use Lovata\Shopaholic\Classes\Event\Category\CategoryModelHandler;
//Currency events
use Lovata\Shopaholic\Classes\Event\Currency\CurrencyModelHandler;
//Measure events
use Lovata\Shopaholic\Classes\Event\Measure\MeasureModelHandler;
//Offer events
use Lovata\Shopaholic\Classes\Event\Offer\OfferModelHandler;
use Lovata\Shopaholic\Classes\Event\Offer\ExtendOfferFieldsHandler;
//Price events
use Lovata\Shopaholic\Classes\Event\Price\PriceModelHandler;
//Product events
use Lovata\Shopaholic\Classes\Event\Product\ProductModelHandler;
use Lovata\Shopaholic\Classes\Event\Product\ProductRelationHandler;
//Promo block events
use Lovata\Shopaholic\Classes\Event\PromoBlock\PromoBlockModelHandler;
use Lovata\Shopaholic\Classes\Event\PromoBlock\PromoBlockRelationHandler;
//Tax events
use Lovata\Shopaholic\Classes\Event\Tax\TaxModelHandler;
use Lovata\Shopaholic\Classes\Event\Tax\TaxRelationHandler;
use Lovata\Shopaholic\Classes\Event\Tax\ExtendTaxFieldsHandler;
/**
* Class Plugin
* @package Lovata\Shopaholic
* @author Andrey Kharanenka, [email protected], LOVATA Group
*/
class Plugin extends PluginBase
{
/** @var array Plugin dependencies */
public $require = ['Lovata.Toolbox'];
/**
* Register artisan command
*/
public function register()
{
$this->registerConsoleCommand('shopaholic:check.table.integrity', CheckTableIntegrity::class);
$this->registerConsoleCommand('shopaholic:import_from_xml', ImportFromXML::class);
$this->registerConsoleCommand('shopaholic:preconfigure_import_from_xml', PreconfigureImportSettingsFromXML::class);
}
/**
* @return array
*/
public function registerComponents()
{
return [
'Lovata\Shopaholic\Components\CategoryList' => 'CategoryList',
'Lovata\Shopaholic\Components\CategoryPage' => 'CategoryPage',
'Lovata\Shopaholic\Components\CategoryData' => 'CategoryData',
'Lovata\Shopaholic\Components\Breadcrumbs' => 'CatalogBreadcrumbs',
'Lovata\Shopaholic\Components\CurrencyList' => 'CurrencyList',
'Lovata\Shopaholic\Components\ProductData' => 'ProductData',
'Lovata\Shopaholic\Components\ProductPage' => 'ProductPage',
'Lovata\Shopaholic\Components\ProductList' => 'ProductList',
'Lovata\Shopaholic\Components\BrandData' => 'BrandData',
'Lovata\Shopaholic\Components\BrandPage' => 'BrandPage',
'Lovata\Shopaholic\Components\BrandList' => 'BrandList',
'Lovata\Shopaholic\Components\PromoBlockData' => 'PromoBlockData',
'Lovata\Shopaholic\Components\PromoBlockPage' => 'PromoBlockPage',
'Lovata\Shopaholic\Components\PromoBlockList' => 'PromoBlockList',
];
}
/**
* @return array
*/
public function registerSettings()
{
return [
'shopaholic-menu-main-settings' => [
'label' => 'lovata.shopaholic::lang.menu.main_settings',
'description' => 'lovata.shopaholic::lang.menu.main_settings_description',
'category' => 'lovata.shopaholic::lang.tab.settings',
'icon' => 'oc-icon-book',
'class' => 'Lovata\Shopaholic\Models\Settings',
'order' => 100,
'permissions' => [
'shopaholic-settings',
],
],
'shopaholic-menu-currency' => [
'label' => 'lovata.shopaholic::lang.menu.currency',
'description' => 'lovata.shopaholic::lang.menu.currency_description',
'category' => 'lovata.shopaholic::lang.tab.settings',
'icon' => 'oc-icon-usd',
'url' => Backend::url('lovata/shopaholic/currencies'),
'order' => 1800,
'permissions' => [
'shopaholic-menu-currency',
],
],
'shopaholic-menu-tax' => [
'label' => 'lovata.shopaholic::lang.menu.tax',
'description' => 'lovata.shopaholic::lang.menu.tax_description',
'category' => 'lovata.shopaholic::lang.tab.settings',
'icon' => 'oc-icon-percent',
'url' => Backend::url('lovata/shopaholic/taxes'),
'order' => 1900,
'permissions' => [
'shopaholic-menu-tax',
],
],
'shopaholic-menu-price-types' => [
'label' => 'lovata.shopaholic::lang.menu.price_type',
'description' => 'lovata.shopaholic::lang.menu.price_type_description',
'category' => 'lovata.shopaholic::lang.tab.settings',
'icon' => 'oc-icon-money',
'url' => Backend::url('lovata/shopaholic/pricetypes'),
'order' => 2000,
'permissions' => [
'shopaholic-menu-price-type',
],
],
'shopaholic-menu-import-xml-file' => [
'label' => 'lovata.shopaholic::lang.menu.import_xml_file',
'description' => 'lovata.shopaholic::lang.menu.import_xml_file_description',
'category' => 'lovata.shopaholic::lang.tab.settings',
'icon' => 'oc-icon-download',
'class' => 'Lovata\Shopaholic\Models\XmlImportSettings',
'order' => 8000,
'permissions' => [
'shopaholic-menu-import-xml-file',
],
],
'shopaholic-menu-measure' => [
'label' => 'lovata.shopaholic::lang.menu.measure',
'description' => 'lovata.shopaholic::lang.menu.measure_description',
'category' => 'lovata.shopaholic::lang.tab.settings',
'url' => Backend::url('lovata/shopaholic/measures'),
'icon' => 'icon-balance-scale',
'permissions' => ['shopaholic-menu-measure'],
'order' => 1650,
],
];
}
/**
* Plugin boot method
*/
public function boot()
{
$this->addEventListener();
}
/**
* Add event listeners
*/
protected function addEventListener()
{
Event::subscribe(ExtendMenuHandler::class);
//Brand events
Event::subscribe(BrandModelHandler::class);
//Category events
Event::subscribe(CategoryModelHandler::class);
//Currency events
Event::subscribe(CurrencyModelHandler::class);
//Measure events
Event::subscribe(MeasureModelHandler::class);
//Offer events
Event::subscribe(OfferModelHandler::class);
Event::subscribe(ExtendOfferFieldsHandler::class);
//Price events
Event::subscribe(PriceModelHandler::class);
//Product events
Event::subscribe(ProductModelHandler::class);
Event::subscribe(ProductRelationHandler::class);
//Promo block events
Event::subscribe(PromoBlockModelHandler::class);
Event::subscribe(PromoBlockRelationHandler::class);
//Tax events
Event::subscribe(TaxModelHandler::class);
Event::subscribe(TaxRelationHandler::class);
Event::subscribe(ExtendTaxFieldsHandler::class);
}
/**
* @return array
*/
public function registerReportWidgets()
{
return [
'Lovata\Shopaholic\Widgets\ImportFromXML' => [
'label' => 'lovata.shopaholic::lang.widget.import_from_xml_files',
],
'Lovata\Shopaholic\Widgets\ImportFromCSV' => [
'label' => 'lovata.shopaholic::lang.widget.import_from_csv_files',
]
];
}
}