Skip to content

Commit 8a8e9f4

Browse files
committed
Load routes by app
1 parent 1b40950 commit 8a8e9f4

File tree

5 files changed

+138
-25
lines changed

5 files changed

+138
-25
lines changed

config/admin-menu.php

+7
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,13 @@
937937
'module' => 'settings/email',
938938
'action' => 'index',
939939
],
940+
'rest' => [
941+
'name' => __('Rest Api'),
942+
'icon' => 'la la-database',
943+
'url' => $admin_path . '?module=settings/email',
944+
'module' => 'settings/email',
945+
'action' => 'index',
946+
],
940947
],
941948
],
942949
],

config/routes.php config/app-routes.php

+23-22
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
'/user/wishlist/add/#product_id#' => ['module' => 'user/wishlist/add'],
5858
'/user/wishlist/remove/#product_id#' => ['module' => 'user/wishlist/remove'],
5959

60+
//user digital assets
61+
'/user/downloads/download/{customer_order_id}-{key}-{public}-#digital_asset_id#' => ['module' => 'user/downloads/download'],
62+
6063
'/user' => ['module' => 'user/index'],
6164

6265
//search
@@ -65,11 +68,6 @@
6568
'/search/{search}/#page#' => ['module' => 'search'],
6669
'/search/{search}/{type}/#page#' => ['module' => 'search'],
6770

68-
//rest api
69-
'/rest/' => ['module' => 'rest'],
70-
'/rest/{method}' => ['module' => 'rest'],
71-
'/rest/{method}/{id}' => ['module' => 'rest'],
72-
7371
//ecommerce
7472

7573
//catalog
@@ -86,23 +84,24 @@
8684
'/vendor/{slug}/#page#' => ['module' => 'product/vendor/index'],
8785
'/vendor' => ['module' => 'product/vendor/index'],
8886
'/vendor/#page#' => ['module' => 'product/vendor/index'],
89-
'/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
87+
//'/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
88+
'/product/{slug}-#product_id#' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&product_id={product_id}'],
9089

9190
//compare
9291
'/cart/compare' => ['module' => 'cart/compare/index'],
9392
'/cart/compare/add/#product_id#' => ['module' => 'cart/compare/add'],
9493
'/cart/compare/remove/#product_id#' => ['module' => 'cart/compare/remove'],
9594

9695
//multi language catalog - language code must be at least 2 characters
97-
'/{language{2,5}}/shop' => ['module' => 'product/index'],
98-
'/{language{2,5}}/shop/#page#' => ['module' => 'product/index'],
99-
'/{language{2,5}}/shop/{slug}' => ['module' => 'product/category/index'],
100-
'/{language{2,5}}/shop/{slug}/#page#' => ['module' => 'product/category/index'],
101-
'/{language{2,5}}/shop/{slug}/#page#/filters-{filters}' => ['module' => 'product/category/index'],
102-
'/{language{2,5}}/manufacturer/{slug}' => ['module' => 'product/manufacturer/index'],
103-
'/{language{2,5}}/vendor/{slug}' => ['module' => 'product/vendor/index'],
104-
'/{language{2,5}}/vendor/{slug}/#page#' => ['module' => 'product/vendor/index'],
105-
'/{language{2,5}}/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
96+
'/{language{2,5}}/shop' => ['module' => 'product/index'],
97+
'/{language{2,5}}/shop/#page#' => ['module' => 'product/index'],
98+
'/{language{2,5}}/shop/{slug}' => ['module' => 'product/category/index'],
99+
'/{language{2,5}}/shop/{slug}/#page#' => ['module' => 'product/category/index'],
100+
'/{language{2,5}}/shop/{slug}/#page#/filters-{filters}' => ['module' => 'product/category/index'],
101+
'/{language{2,5}}/manufacturer/{slug}' => ['module' => 'product/manufacturer/index'],
102+
'/{language{2,5}}/vendor/{slug}' => ['module' => 'product/vendor/index'],
103+
'/{language{2,5}}/vendor/{slug}/#page#' => ['module' => 'product/vendor/index'],
104+
'/{language{2,5}}/product/{slug}-#product_id#' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&product_id={product_id}'],
106105

107106
//checkout
108107
'/cart' => ['module' => 'cart/cart/index'],
@@ -142,21 +141,23 @@
142141

143142
//post
144143
//'/#year{4,4}#-#month{1,2}#-#day#/{slug}' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&slug={slug}'],
145-
'/{slug}' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&slug={slug}&type=post'],
144+
//'/{slug}' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&slug={slug}&type=post'],
145+
'/{slug}-#post_id#' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&post_id={post_id}&type=post'],
146146
//page
147147
//'/{slug}' => ['module' => 'content/page/index', 'edit'=>'?module=content/post&slug={slug}'],
148-
'/page/{slug}' => ['module' => 'content/page/index', 'edit'=>'?module=content/post&slug={slug}&type=page'],
148+
//'/page/{slug}' => ['module' => 'content/page/index', 'edit'=>'?module=content/post&slug={slug}&type=page'],
149+
'/page/{slug}-#post_id#' => ['module' => 'content/page/index', 'edit'=>'?module=content/post&post_id={post_id}&type=page'],
149150

150151
//multi language content - language code must be at least 2 characters
151152
'/{language{2,5}}/' => ['module' => 'index/index'],
152153
//pagination for blog posts
153154
'/{language{2,5}}/p/#page#' => ['module' => 'index/index'],
154155
//content
155-
'/{language{2,5}}/blog' => ['module' => 'content'],
156-
'/{language{2,5}}/cat/{slug}' => ['module' => 'content/category/language'],
157-
'/{language{2,5}}/tag/{slug}' => ['module' => 'content/tag/index'],
158-
'/{language{2,5}}/{slug}' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&slug={slug}'],
159-
'/{language{2,5}}/page/{slug}' => ['module' => 'content/page/index', 'edit'=>'?module=content/post&slug={slug}'],
156+
'/{language{2,5}}/blog' => ['module' => 'content'],
157+
'/{language{2,5}}/cat/{slug}' => ['module' => 'content/category/language'],
158+
'/{language{2,5}}/tag/{slug}' => ['module' => 'content/tag/index'],
159+
'/{language{2,5}}/{slug}-#post_id#' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&post_id={post_id}'],
160+
'/{language{2,5}}/page/{slug}-#post_id#' => ['module' => 'content/page/index', 'edit'=>'?module=content/post&post_id={post_id}'],
160161

161162
'/{language{2,5}}/tag/{slug}' => ['module' => 'content/tag/index'],
162163
'/{language{2,5}}/tag/{slug}/#page#' => ['module' => 'content/tag/index'],

config/rest-routes.php

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
/**
4+
* Vvveb
5+
*
6+
* Copyright (C) 2022 Ziadin Givan
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
return [
24+
'/rest/' => ['module' => 'index'],
25+
26+
//posts
27+
'/rest/posts' => ['module' => 'posts'],
28+
'/rest/posts/#post_id#' => ['module' => 'posts/post/index'],
29+
'/rest/posts/{slug}' => ['module' => 'posts/post/index'],
30+
//revisions
31+
'/rest/posts/#post_id#/revisions' => ['module' => 'posts/revisions/index'],
32+
'/rest/posts/#post_id#/revisions/{created_at}' => ['module' => 'posts/revision/index'],
33+
//pages
34+
35+
//comments
36+
'/rest/posts/#post_id#/comments' => ['module' => 'posts/comments/index'],
37+
'/rest/posts/#post_id#/comments/{created_at}' => ['module' => 'posts/comment/index'],
38+
39+
//media
40+
'/rest/media' => ['module' => 'media'],
41+
'/rest/media/{file}' => ['module' => 'media/media/index'],
42+
43+
//menus
44+
'/rest/menus' => ['module' => 'menus'],
45+
'/rest/menus/{menu_id}' => ['module' => 'menus/v/index'],
46+
//menu-items
47+
'/rest/menu-items' => ['module' => 'menu-items'],
48+
'/rest/menu-items/{menu_id}' => ['module' => 'menu-items/menu-items/index'],
49+
50+
//taxonomies
51+
'/rest/taxonomies' => ['module' => 'taxonomies'],
52+
'/rest/taxonomies/{menu_id}' => ['module' => 'taxonomies/taxonomies/index'],
53+
//tags
54+
//categories
55+
56+
//users
57+
'/rest/users' => ['module' => 'users'],
58+
'/rest/users/#user_id#' => ['module' => 'users/user/index'],
59+
60+
//search
61+
'/rest/search' => ['module' => 'search'],
62+
63+
//settings
64+
'/rest/settings' => ['module' => 'settings'],
65+
66+
//themes
67+
'/rest/themes' => ['module' => 'settings'],
68+
'/rest/themes/{slug}' => ['module' => 'themes/themes/index'],
69+
70+
//plugins
71+
'/rest/plugins' => ['module' => 'plugins'],
72+
'/rest/plugins/{slug}' => ['module' => 'plugins/plugins/index'],
73+
74+
//languages
75+
76+
//ecommerce
77+
78+
//products
79+
'/rest/products' => ['module' => 'products'],
80+
'/rest/products/#product_id#' => ['module' => 'products/product/index'],
81+
'/rest/products/{slug}' => ['module' => 'products/products/index'],
82+
83+
//product attributes
84+
//product reviews
85+
//product questions
86+
//taxonomies
87+
//tags
88+
//categories
89+
90+
//orders
91+
//coupons
92+
//tax rates
93+
//tax classes
94+
//tax types
95+
//returns
96+
//zones
97+
//countries
98+
//currencies
99+
100+
//payment methods
101+
//shipping methods
102+
103+
//stats
104+
];

config/sites.php

+1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
'state' => 'live',
2929
'template' => '',
3030
'id' => 1,
31+
'site_id' => 1,
3132
],
3233
];

system/routes.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Routes {
3737

3838
private static $routes = [];
3939

40-
private static $urls = null;
40+
private static $urls = [];
4141

4242
private static $modules = null;
4343

@@ -102,8 +102,8 @@ public static function removeRoute($url) {
102102
}
103103
}
104104

105-
public static function init() {
106-
self :: $routes += include DIR_ROOT . '/config/routes.php';
105+
public static function init($app = 'app') {
106+
self :: $routes += include DIR_ROOT . "/config/$app-routes.php";
107107
list(self :: $routes) = Event::trigger(__CLASS__, __FUNCTION__ , self :: $routes);
108108

109109
foreach (self :: $routes as $url => $data) {

0 commit comments

Comments
 (0)