config
This commit is contained in:
2
app_old/ui/middlewares/01_auth.php
Normal file
2
app_old/ui/middlewares/01_auth.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$app->add($app->getContainer()->get(App\Middleware\Auth::class));
|
20
app_old/ui/middlewares/02_databases.php
Normal file
20
app_old/ui/middlewares/02_databases.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
function loadDatabase(object $settings, string $name): void
|
||||
{
|
||||
$port = 3306;
|
||||
if (isset($settings->port)) {
|
||||
$port = $settings->port;
|
||||
}
|
||||
$dsn = 'mysql:host=' . $settings->host . ';port=' . $port . ';dbname=' . $settings->database . ';charset=utf8';
|
||||
|
||||
ORM::configure($dsn, null, $name);
|
||||
ORM::configure('username', $settings->username, $name);
|
||||
ORM::configure('password', $settings->password, $name);
|
||||
}
|
||||
|
||||
$databases = $app->getContainer()->get('databases');
|
||||
foreach ($databases as $name => $settings) {
|
||||
loadDatabase($settings, $name);
|
||||
}
|
||||
|
||||
Model::$short_table_names = true;
|
2
app_old/ui/middlewares/98_logs.php
Normal file
2
app_old/ui/middlewares/98_logs.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
Monolog\ErrorHandler::register($app->getContainer()->get(Psr\Log\LoggerInterface::class));
|
15
app_old/ui/middlewares/99_routes.php
Normal file
15
app_old/ui/middlewares/99_routes.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
function buildRoutes(&$app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [
|
||||
$app->getContainer()->get('folders')->get('routes'),
|
||||
'ui'
|
||||
]);
|
||||
$files = new FilesystemIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
buildRoutes($app);
|
Reference in New Issue
Block a user