From 804ea59c974becdc5846675c3dff7c7ca388d4c6 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 8 Jun 2019 01:30:50 +0300 Subject: [PATCH] Flextype Box Plugin: Admin #125 #117 - admin route can be changed --- site/plugins/admin/bootstrap.php | 7 ++++++- site/plugins/admin/routes/web.php | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/site/plugins/admin/bootstrap.php b/site/plugins/admin/bootstrap.php index c97542d4..58485b86 100755 --- a/site/plugins/admin/bootstrap.php +++ b/site/plugins/admin/bootstrap.php @@ -17,9 +17,14 @@ use Flextype\Component\Arr\Arr; use Flextype\Component\I18n\I18n; use function Flextype\Component\I18n\__; +// Get URI $uri = explode('/', \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getPath()); -if (isset($uri) && isset($uri[0]) && $uri[0] == 'admin') { +// Set base admin route +$admin_route = 'admin'; + +// Run Admin for admin_route +if (isset($uri) && isset($uri[0]) && $uri[0] == $admin_route) { // Ensure vendor libraries exist !is_file($autoload = __DIR__ . '/vendor/autoload.php') and exit("Please run: composer install"); diff --git a/site/plugins/admin/routes/web.php b/site/plugins/admin/routes/web.php index 6ad48bad..8a228902 100644 --- a/site/plugins/admin/routes/web.php +++ b/site/plugins/admin/routes/web.php @@ -2,22 +2,18 @@ namespace Flextype; -// Set base admin route -$admin_route = '/admin'; - // Site $app->get('/', '')->setName('admin.site.index'); - // UsersController -$app->group($admin_route, function () use ($flextype, $app) { +$app->group('/' . $admin_route, function () use ($flextype, $app) { $app->get('/registration', 'UsersController:registration')->setName('admin.users.registration'); $app->post('/registration', 'UsersController:registrationProcess')->setName('admin.users.registrationProcess'); $app->get('/login', 'UsersController:login')->setName('admin.users.login'); $app->post('/login', 'UsersController:loginProcess')->setName('admin.users.loginProcess'); }); -$app->group($admin_route, function () use ($flextype, $app) { +$app->group('/' . $admin_route, function () use ($flextype, $app) { // UsersController $app->get('/profile', 'UsersController:profile')->setName('admin.users.profile');