Repository navigation
Expand file tree
/
Copy pathProvider.php
More file actions
144 lines (124 loc) · 7.77 KB
/
Copy pathProvider.php
File metadata and controls
144 lines (124 loc) · 7.77 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
<?php
$config = file_get_contents(__DIR__.'/gp247.json');
$config = json_decode($config, true);
$extensionPath = $config['configGroup'].'/'.$config['configKey'];
$this->loadTranslationsFrom(__DIR__.'/Lang', $extensionPath);
$this->loadViewsFrom(__DIR__.'/Views', $extensionPath);
if (gp247_extension_check_active($config['configGroup'], $config['configKey'])) {
$this->commands([
\App\GP247\Plugins\MultiVendor\Commands\SampleData::class,
]);
config(['auth.guards.vendor.driver' => 'session']);
config(['auth.guards.vendor.provider' => 'vendors']);
config(['auth.providers.vendors.driver' => 'eloquent']);
config(['auth.providers.vendors.model' => 'App\GP247\Plugins\MultiVendor\Models\VendorUser']);
config(['auth.passwords.vendors.provider' => 'vendors']);
config(['auth.passwords.vendors.table' => 'vendor_password_resets']);
config(['auth.passwords.vendors.expire' => '60']);
app('router')->aliasMiddleware('checkStoreExist', \App\GP247\Plugins\MultiVendor\Middleware\CheckStoreExist::class);
app('router')->aliasMiddleware('checkVendorActive', \App\GP247\Plugins\MultiVendor\Middleware\CheckVendorActive::class);
app('router')->aliasMiddleware('vendor.auth', \App\GP247\Plugins\MultiVendor\Middleware\Authenticate::class);
app('router')->aliasMiddleware('vendor.storeId', \App\GP247\Plugins\MultiVendor\Middleware\AdminStoreId::class);
app('router')->middlewareGroup('vendor', ['vendor.auth', 'vendor.storeId', 'localization']);
//Load helper
foreach (glob(__DIR__.'/Helpers/*.php') as $filename) {
require_once $filename;
}
if (file_exists(__DIR__.'/config.php')) {
$this->mergeConfigFrom(__DIR__.'/config.php', $extensionPath);
}
// A period payout can be paid through the core's payment requests.
\App\GP247\Plugins\MultiVendor\Payout\VendorPayoutPurpose::register();
// WHY: store the i18n KEY, not the raw token — the "Layout block" admin
// screen renders each option through gp247_language_render(), so a raw
// token showed up untranslated as "vendor_home - vendor_home".
// Keys must stay equal to the $layout_page value FrontController emits.
$configLayoutPage = config('gp247-config.front.layout_page', []);
$configLayoutPage['vendor_home'] = $extensionPath.'::lang.layout_block_page.vendor_home';
$configLayoutPage['vendor_product_list'] = $extensionPath.'::lang.layout_block_page.vendor_product_list';
$configLayoutPage['vendor_index'] = $extensionPath.'::lang.layout_block_page.vendor_index';
config(['gp247-config.front.layout_page' => $configLayoutPage]);
// S3-3: dispute box under the customer's order page through the storefront
// extension point (ADR front_storefront-plugin-hooks) — no template edit
// needed once the screen calls gp247_render_plugin_hook('shop_order_detail_bottom').
$hooks = config('gp247-config.front.plugin_hooks', []);
$hooks['shop_order_detail_bottom'][] = [
'key' => 'MultiVendor',
'callback' => [\App\GP247\Plugins\MultiVendor\Hooks\OrderDetailHook::class, 'render'],
];
config(['gp247-config.front.plugin_hooks' => $hooks]);
// The "Top new vendors" storefront block, offered to the Layout block screen
// by REGISTERING it (ADR frontend-template-dev_plugin-layout-block-views).
//
// Until modification 20260922T205500 install() copied the blade into
// app/GP247/Templates/<active template>/blocks/. That copy needed a writable
// directory (a read-only deploy silently ended up with no block at all), only
// ever reached the template active at install time, was never refreshed by an
// update, and stayed behind as an orphan file when the plugin was removed.
// A template that wants to draw the block itself still wins: gp247_render_block()
// looks its file up first.
$blockViews = config('gp247-config.front.layout_block_views', []);
$blockViews['vendor_new'] = $extensionPath.'::blocks.vendor_new';
config(['gp247-config.front.layout_block_views' => $blockViews]);
// Vendor products use the marketplace's categories / brands / taxes — on every
// product screen, the vendor's and the marketplace admin's (gp247/shop resolver).
$referenceResolvers = config('gp247-config.shop.product_reference_store_resolvers', []);
$referenceResolvers[] = [
'key' => \App\GP247\Plugins\MultiVendor\Catalogue\MarketplaceTaxonomy::RESOLVER_KEY,
'callback' => [\App\GP247\Plugins\MultiVendor\Catalogue\MarketplaceTaxonomy::class, 'referenceStore'],
];
config(['gp247-config.shop.product_reference_store_resolvers' => $referenceResolvers]);
// The core product cleanup (ShopProduct::boot deleting) only knows core tables;
// the shop-category link is this plugin's, so it goes with the product here —
// on every delete path (vendor screen, marketplace admin screen, destroy()).
\GP247\Shop\Models\ShopProduct::deleting(function ($product) {
\App\GP247\Plugins\MultiVendor\Models\VendorProductCategory::where('product_id', $product->id)->delete();
});
//Config for file manager
$configLfm = config('lfm.folder_categories');
$formatConfig = [
'folder_name' => 'format_folder_name',
'startup_view' => 'grid',
'max_size' => 30000, // size in KB
'valid_mime' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
'image/webp'
],
];
// WHY 'category_store' is in this list: the vendor category screen's file
// picker asks for the 'vendor_category_store' category. It was never
// registered, so the picker had no folder config to work with.
foreach (['product', 'category', 'category_store', 'supplier', 'customer','logo','avatar','banner','page'] as $item) {
$formatConfigTmp = $formatConfig;
$formatConfigTmp['folder_name'] = $item;
$configLfm['vendor_'.$item] = $formatConfigTmp;
}
config(['lfm.folder_categories' => $configLfm]);
// Marketplace e-mails (S1-2, US-multi-vendor-pro-marketplace-notifications).
//
// WHY a model event + DB::afterCommit instead of a core hook: gp247/shop has
// no order event to listen to and the "new order" mail must not touch core
// (NFR-mv-no-core-front-change). ShopOrder::created fires for every source
// (checkout AND admin-created orders); afterCommit defers the mail until the
// order lines exist — checkout inserts the details after the order row, in
// the same transaction. Outside a transaction the callback runs immediately.
\GP247\Shop\Models\ShopOrder::created(function ($order) {
\Illuminate\Support\Facades\DB::afterCommit(function () use ($order) {
\App\GP247\Plugins\MultiVendor\Notifications\VendorNotifier::orderCreated($order);
});
});
// Vendor self-registration lands here (RegisterController dispatches
// CreatedVendorUser); the notifier itself skips stores that are already open.
\Illuminate\Support\Facades\Event::listen(
\App\GP247\Plugins\MultiVendor\Events\CreatedVendorUser::class,
function ($event) {
\App\GP247\Plugins\MultiVendor\Notifications\VendorNotifier::vendorRegistered($event->data);
}
);
//Path view admin
view()->share('templatePathAdminVendor', $extensionPath.'::Admin.');
}