-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.example.php
More file actions
114 lines (102 loc) · 3.94 KB
/
bootstrap.example.php
File metadata and controls
114 lines (102 loc) · 3.94 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
<?php
/**
* Created for plugin-core-logistic
* Date: 30.11.2020
* @author Timur Kasumov (XAKEPEHOK)
*/
use Medoo\Medoo;
use SalesRender\Plugin\Components\Batch\BatchContainer;
use SalesRender\Plugin\Components\Db\Components\Connector;
use SalesRender\Plugin\Components\Form\Autocomplete\AutocompleteRegistry;
use SalesRender\Plugin\Components\Form\Form;
use SalesRender\Plugin\Components\Form\TableView\TablePreviewRegistry;
use SalesRender\Plugin\Components\Info\Developer;
use SalesRender\Plugin\Components\Info\Info;
use SalesRender\Plugin\Components\Info\PluginType;
use SalesRender\Plugin\Components\Purpose\LogisticPluginClass;
use SalesRender\Plugin\Components\Purpose\PluginEntity;
use SalesRender\Plugin\Components\Settings\Settings;
use SalesRender\Plugin\Components\Translations\Translator;
use SalesRender\Plugin\Core\Actions\Upload\LocalUploadAction;
use SalesRender\Plugin\Core\Actions\Upload\UploadersContainer;
use SalesRender\Plugin\Core\Logistic\Components\Actions\Shipping\ShippingContainer;
use SalesRender\Plugin\Core\Logistic\Components\BatchShippingHandler;
use SalesRender\Plugin\Core\Logistic\Components\Fulfillment\FulfillmentContainer;
use SalesRender\Plugin\Core\Logistic\Components\Waybill\WaybillContainer;
use SalesRender\Plugin\Core\Logistic\Components\Waybill\WaybillHandlerInterface;
use XAKEPEHOK\Path\Path;
# 1. Configure DB (for SQLite *.db file and parent directory should be writable)
Connector::config(new Medoo([
'database_type' => 'sqlite',
'database_file' => Path::root()->down('db/database.db')
]));
# 2. Set plugin default language
Translator::config('ru_RU');
# 3. Set permitted file extensions (* for any ext) and max sizes (in bytes). Pass empty array for disable file uploading
UploadersContainer::addDefaultUploader(new LocalUploadAction([
'jpg' => 100 * 1024, //Max 100 KB for *.jpg file
'zip' => 10 * 1024 * 1024, //Max 10 MB for *.zip archive
]));
# 4. Configure info about plugin
Info::config(
new PluginType(PluginType::MACROS),
fn() => Translator::get('info', 'Plugin name'),
fn() => Translator::get('info', 'Plugin markdown description'),
[
"class" => LogisticPluginClass::CLASS_DELIVERY,
"entity" => PluginEntity::ENTITY_UNSPECIFIED,
"country" => "RU",
"codename" => "DPD",
"geocoder" => false,
],
new Developer(
'Your (company) name',
'support.for.plugin@example.com',
'example.com',
)
);
# 5. Configure settings form
Settings::setForm(fn(array $context) => new Form($context));
# 6. Configure form autocompletes (or remove this block if dont used)
AutocompleteRegistry::config(function (string $name) {
// switch ($name) {
// case 'status': return new StatusAutocomplete();
// case 'user': return new UserAutocomplete();
// default: return null;
// }
});
# 7. Configure form autocompletes (or remove this block if dont used)
TablePreviewRegistry::config(function (string $name) {
// switch ($name) {
// case 'excel': return new ExcelTablePreview();
// case 'calc': return new CalcTablePreview();
// default: return null;
// }
});
# 8. Configure batch forms and handler (or remove this block if dont used)
BatchContainer::config(
function (int $number, array $context) {
// switch ($number) {
// case 1: return new Form($context);
// case 2: return new Form($context);
// case 3: return new Form($context);
// default: return null;
// }
},
new BatchShippingHandler()
);
# 9. Configure waybill form and handler
WaybillContainer::config(
fn(array $context) => new WaybillForm($context),
new WaybillHandlerInterface()
);
# 10. Configure shipping cancel action (only for delivery plugins)
ShippingContainer::config(
new ShippingCancelAction(),
new RemoveOrdersAction(),
);
# 11. Configure fulfillment sync action
FulfillmentContainer::config(
new FulfillmentBindingHandlerInterface(),
new FulfillmentSyncHandlerInterface()
);