2022-10-21 14:31:48 +02:00
|
|
|
<?php
|
2022-10-24 20:20:52 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022. Micha Espey <tracer@24unix.net>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-10-21 14:31:48 +02:00
|
|
|
ini_set(option: 'display_errors', value: 1);
|
|
|
|
ini_set(option: 'display_startup_errors', value: 1);
|
2022-10-24 20:20:52 +02:00
|
|
|
// no one sane should ignore deprecations
|
2022-10-21 14:31:48 +02:00
|
|
|
error_reporting(error_level: E_ALL);
|
|
|
|
|
2022-10-24 20:20:52 +02:00
|
|
|
session_start();
|
|
|
|
|
2022-10-21 14:31:48 +02:00
|
|
|
require dirname(path: __DIR__) . '/src/bootstrap.php';
|
|
|
|
|
2022-10-24 20:20:52 +02:00
|
|
|
use App\Controller\AddressBookAdminController;
|
|
|
|
use App\Controller\AddressBookController;
|
|
|
|
use App\Controller\SecurityController;
|
|
|
|
use App\Service\Container;
|
|
|
|
use App\Service\Router;
|
|
|
|
|
|
|
|
$container = new Container();
|
|
|
|
$router = $container->get(className: Router::class);
|
|
|
|
$security = $container->get(className: SecurityController::class);
|
|
|
|
$addressBook = $container->get(className: AddressBookController::class);
|
|
|
|
$addressBookAdmin = $container->get(className: AddressBookAdminController::class);
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_login', route: '/login', callback: function () use ($security) {
|
|
|
|
$security->login();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_logout', route: '/logout', callback: function () use ($security) {
|
|
|
|
$security->logout();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_main', route: '/', callback: function () use ($addressBook) {
|
|
|
|
$addressBook->main();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_admin', route: '/admin', callback: function () use ($addressBookAdmin) {
|
|
|
|
$addressBookAdmin->admin();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_admin_users', route: '/admin/users', callback: function () use ($addressBookAdmin) {
|
|
|
|
$addressBookAdmin->adminUser();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_admin_users_edit', route: '/admin/users/{nick}', callback: function (array $parameters) use ($addressBookAdmin) {
|
|
|
|
$addressBookAdmin->adminUserEdit(parameters: $parameters);
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_admin_users_add', route: '/admin/users/add', callback: function () use ($addressBookAdmin) {
|
|
|
|
$addressBookAdmin->adminUserAdd();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'app_admin_users_delete', route: '/admin/users/delete/{nick}', callback: function (array $parameters) use ($addressBookAdmin) {
|
|
|
|
$addressBookAdmin->adminUserDelete(parameters: $parameters);
|
|
|
|
});
|
2022-10-21 14:31:48 +02:00
|
|
|
|
2022-10-25 15:57:46 +02:00
|
|
|
$router->addRoute(name: 'address_add', route: '/address/add', callback: function () use ($addressBook) {
|
|
|
|
$addressBook->addAddress();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'address_add', route: '/address/update', callback: function () use ($addressBook) {
|
|
|
|
$addressBook->updateAddress();
|
|
|
|
});
|
|
|
|
|
|
|
|
$router->addRoute(name: 'address_add', route: '/address/delete', callback: function () use ($addressBook) {
|
|
|
|
$addressBook->deleteAddress();
|
|
|
|
});
|
2022-10-21 14:31:48 +02:00
|
|
|
|
2022-10-24 20:20:52 +02:00
|
|
|
$router->handleRouting();
|