-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
75 lines (61 loc) · 2.6 KB
/
Copy pathbootstrap.php
File metadata and controls
75 lines (61 loc) · 2.6 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
<?php
$this->on('app.admin.init', function () {
include __DIR__ . '/admin.php';
});
$this->on('app.api.request', function () {
include __DIR__ . '/api.php';
});
$app->on('app.admin.request', function () use ($app) {
$app->bind('/shop/finished-order', function () use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'finishedOrder');
});
$storeFront = $app->retrieve('onlineshop') ?? [];
if (!empty($storeFront['mainPageEnable'])) {
$shopSettings = $app->dataStorage->findOne('store/settings', ['_id' => 'config']) ?? [];
$shopName = $shopSettings['shop_name'] ?? 'Online Coffee Store';
$shopSlug = \strtolower(\preg_replace('/[^a-zA-Z0-9-]/', '', \str_replace(' ', '-', $shopName)));
$shopSlug = \preg_replace('/-+/', '-', $shopSlug);
$dashRoute = '/dash-' . $shopSlug;
$app->bind('/', function () use ($app) {
if ($app->helper('auth')->getUser()) {
return $app->reroute('/store');
}
return $app->invoke('Store\\Controller\\Shop', 'index');
});
$app->bind('/tracker', function () use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'tracker');
});
$app->bind('/dashboard', function () use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'dashboard');
});
$app->bind('/about', function () use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'about');
});
$app->bind('/faq', function () use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'faq');
});
$app->bind('/security', function () use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'security');
});
$app->bind('/product/:id', function ($params) use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'product', ['id' => $params['id']]);
});
$app->bind($dashRoute, function () use ($app) {
if ($app->helper('auth')->getUser()) {
return $app->reroute('/store');
}
return $app->invoke('App\\Controller\\Auth', 'login');
});
$route = $app->request->route ?? '';
if ($route === '/auth/login') {
$to = $app->param('to');
if ($to) {
return $app->reroute($dashRoute . '?to=' . \urlencode($to));
}
return $app->reroute('/');
}
$app->bind('/finished-order', function () use ($app) {
return $app->invoke('Store\\Controller\\Shop', 'finishedOrder');
});
}
});