First Commit
This commit is contained in:
Executable
+64
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2025 Marco Costa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Marco Costa
|
||||
* Email: contato@syspanel.com.br
|
||||
* Project: SysCMS
|
||||
*
|
||||
* This software is licensed, not sold.
|
||||
* Permission is granted to use this software
|
||||
* subject to the terms of the SysCMS Commercial License.
|
||||
*
|
||||
* Redistribution, sublicensing, resale, or
|
||||
* disclosure of this software, in whole or in part,
|
||||
* is strictly prohibited without prior written permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
||||
*/
|
||||
|
||||
use Kernel\Application;
|
||||
|
||||
/**
|
||||
* Register index module routes
|
||||
*
|
||||
* @param Application $app
|
||||
* @return void
|
||||
*/
|
||||
return function (Application $app) {
|
||||
// Homepage route
|
||||
$app->addRoute('GET', '/', [\Modules\Index\Controllers\IndexController::class, 'index']);
|
||||
|
||||
// Static pages
|
||||
$app->addRoute('GET', '/about', [\Modules\Index\Controllers\IndexController::class, 'about']);
|
||||
$app->addRoute('GET', '/services', [\Modules\Index\Controllers\IndexController::class, 'services']);
|
||||
|
||||
// Language switcher route
|
||||
$app->addRoute('GET', '/language/{lang}', [\Modules\Index\Controllers\IndexController::class, 'changeLanguage']);
|
||||
|
||||
// Dynamic pages from ConfigPage
|
||||
if (class_exists('Modules\Configindex\Models\ConfigPage')) {
|
||||
try {
|
||||
$busId = $_SESSION['current_company_id'] ?? 1;
|
||||
$pages = \Modules\Configindex\Models\ConfigPage::where('config_index_bus_id', $busId)->get();
|
||||
foreach ($pages as $page) {
|
||||
$key = $page->config_index_key;
|
||||
if (!in_array($key, ['index', 'about', 'services', 'contact'])) {
|
||||
$app->addRoute('GET', '/' . $key, function ($request) use ($key) {
|
||||
$controller = \Kernel\Application::getInstance()->getContainer()->get(\Modules\Index\Controllers\IndexController::class);
|
||||
return $controller->page($request, $key);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Table might not exist yet
|
||||
}
|
||||
}
|
||||
|
||||
// Category route
|
||||
$app->addRoute('GET', '/category/{category}', [\Modules\Index\Controllers\IndexController::class, 'category']);
|
||||
};
|
||||
Reference in New Issue
Block a user