added all needed routes (so far)
This commit is contained in:
parent
cfc4e22497
commit
e1d1ef5eeb
|
@ -1,13 +1,68 @@
|
||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
ini_set(option: 'display_errors', value: 1);
|
ini_set(option: 'display_errors', value: 1);
|
||||||
ini_set(option: 'display_startup_errors', value: 1);
|
ini_set(option: 'display_startup_errors', value: 1);
|
||||||
|
// no one sane should ignore deprecations
|
||||||
error_reporting(error_level: E_ALL);
|
error_reporting(error_level: E_ALL);
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
require dirname(path: __DIR__) . '/src/bootstrap.php';
|
require dirname(path: __DIR__) . '/src/bootstrap.php';
|
||||||
|
|
||||||
use App\Controller\AddressBook;
|
use App\Controller\AddressBookAdminController;
|
||||||
|
use App\Controller\AddressBookController;
|
||||||
|
use App\Controller\SecurityController;
|
||||||
|
use App\Service\Container;
|
||||||
|
use App\Service\Router;
|
||||||
|
|
||||||
$container = new \App\Service\Container();
|
$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);
|
||||||
|
|
||||||
$addressBook = $container->get(AddressBook::class);
|
|
||||||
//$addressBook = new AddressBook();
|
// TODO maybe refactor route adding to the controllers?
|
||||||
|
// I currently think that makes sense.
|
||||||
|
|
||||||
|
$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);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$router->handleRouting();
|
Loading…
Reference in New Issue