diff --git a/protected/src/configs/on_footer_banner.php b/protected/src/configs/on_footer_banner.php index 12125c0..c6cd9fd 100644 --- a/protected/src/configs/on_footer_banner.php +++ b/protected/src/configs/on_footer_banner.php @@ -9,8 +9,8 @@ declare(strict_types=1); */ namespace Project; -function get_footer(): string { - return ''; + + public const string MyAuthors = 'Robert Strutts, plus ME!'; } \ No newline at end of file diff --git a/protected/src/controllers/app/cookie_ctrl.php b/protected/src/controllers/app/cookie_ctrl.php index c2f9294..d596556 100644 --- a/protected/src/controllers/app/cookie_ctrl.php +++ b/protected/src/controllers/app/cookie_ctrl.php @@ -10,7 +10,6 @@ declare(strict_types = 1); namespace Project\controllers\app; use \CodeHydrater\base_controller; -use \CodeHydrater\http\response as Response; use \CodeHydrater\enums\exit_on_dump as endDump; class cookie_ctrl extends base_controller { @@ -19,7 +18,7 @@ class cookie_ctrl extends base_controller { \CodeHydrater\security::init_sessions(); // Init Sessions } - public function save(): Response { + public function save() { $_SESSION['testing_user'] = "Bob"; $_SESSION['awesome'] = true; @@ -27,7 +26,7 @@ class cookie_ctrl extends base_controller { return $this->response; } - public function read(): Response { + public function read() { dd($_SESSION, endDump::keep_working); // var_dump($_SESSION['admin'] ?? ""); return $this->response; diff --git a/protected/src/controllers/app/home_ctrl.php b/protected/src/controllers/app/home_ctrl.php index 30f6555..1eb8ea1 100644 --- a/protected/src/controllers/app/home_ctrl.php +++ b/protected/src/controllers/app/home_ctrl.php @@ -11,28 +11,19 @@ namespace Project\controllers\app; use \CodeHydrater\base_controller; use \CodeHydrater\enums\view_type as ViewType; -use \CodeHydrater\http\response as Response; /** * Description of home_ctrl URL Route: /FOLDER/FILE/METHOD * /app/home/name_demo */ class home_ctrl extends base_controller { - private $footer; - + public function init() { - // FROM on_footer_banner.php in the configs folder... - if (function_exists("\Project\get_footer")) { - $this->footer = \Project\get_footer(); - } else { - $this->footer = ""; - } + // Defined from: on_footer_banner.php in the configs folder... + $this->set_footer_and_authors(); } - public function index(): Response { - $this->html->set_footer($this->footer); - $this->html->set_author("Robert Strutts, plus ME!"); - + public function index() { $this->view->set('html', $this->html); $this->view->set_template('main'); $this->view->include("app/header", ViewType::PHP); @@ -43,7 +34,7 @@ class home_ctrl extends base_controller { return $this->response; } - public function name_demo(): Response { + public function name_demo() { echo $this->footer; $this->view->set('twig_data', ['name' => "John Doe"]); @@ -53,7 +44,7 @@ class home_ctrl extends base_controller { return $this->response; } - public function liquid(): Response { + public function liquid() { echo $this->footer; $this->view->set('template_assigns', [ 'name' => "James Smith", @@ -65,7 +56,7 @@ class home_ctrl extends base_controller { return $this->response; } - public function extra(): Response { + public function extra() { $loaded = \CodeHydrater\extras_booter::tryToEnableFeature("testing", refresh: true); if ($loaded === false) { $content = "Unable to load Feature..."; @@ -77,31 +68,11 @@ class home_ctrl extends base_controller { return $this->response; } - public function make_hash(): Response { + public function make_hash() { $content = \CodeHydrater\security::do_password_hash("Hello, World"); $this->response->set_content($content); return $this->response; } - /** - * from Routes - * - */ - public function test(int $id): Response { - $content = "The ID for Test Example is # $id"; - - $this->response->set_content($content); - return $this->response; - } - - public function demo(?string $name="Test", ?int $limit=10, ?int $page=1): Response { - $content = "DEMO Name: ". \CodeHydrater\bootstrap\safer_io::p($name); - $content .= "LIMIT = ". $limit; - $content .= "PAGE = ". $page; - - $this->response->set_content($content); - return $this->response; - } - } diff --git a/protected/src/controllers/app/jwt_ctrl.php b/protected/src/controllers/app/jwt_ctrl.php index 2a7584f..0c11890 100644 --- a/protected/src/controllers/app/jwt_ctrl.php +++ b/protected/src/controllers/app/jwt_ctrl.php @@ -11,12 +11,11 @@ namespace Project\controllers\app; use \CodeHydrater\base_controller; use CodeHydrater\bootstrap\registry as Reg; -use \CodeHydrater\http\response as Response; use \CodeHydrater\enums\exit_on_dump as endDump; class jwt_ctrl extends base_controller { - public function index(): Response { + public function index() { // Payload data (customize as needed) $payload = [ 'iss' => 'your-issuer', // Issuer @@ -36,7 +35,7 @@ class jwt_ctrl extends base_controller { return $this->response; } - public function read(array $p): Response { + public function read(array $p) { $token = $p['token'] ?? false; if ($token === false) { echo "Sorry, no token in URL"; diff --git a/protected/src/controllers/app/protected_ctrl.php b/protected/src/controllers/app/protected_ctrl.php index 432995f..dd47998 100644 --- a/protected/src/controllers/app/protected_ctrl.php +++ b/protected/src/controllers/app/protected_ctrl.php @@ -10,7 +10,6 @@ declare(strict_types = 1); namespace Project\controllers\app; use \CodeHydrater\base_controller; -use \CodeHydrater\http\response as Response; /** * Description of protected_ctrl @@ -25,7 +24,7 @@ class protected_ctrl extends base_controller { \Project\classes\auth_middleware::class ]; - public function index(): Response { + public function index() { $this->response->set_content("Coool!"); return $this->response; } diff --git a/protected/src/controllers/app/testing_ctrl.php b/protected/src/controllers/app/testing_ctrl.php index 821d531..c65adf0 100644 --- a/protected/src/controllers/app/testing_ctrl.php +++ b/protected/src/controllers/app/testing_ctrl.php @@ -10,7 +10,6 @@ declare(strict_types = 1); namespace Project\controllers\app; use CodeHydrater\base_controller; -use CodeHydrater\http\response as Response; /** * Description of testing_ctrl @@ -34,7 +33,7 @@ class testing_ctrl extends base_controller { return str_replace('CodeHydrater', '_', $results). "\n
"; } - public function count_files(): Response { + public function count_files() { // Disable on production as you don't want to expose FW info... // exit(0); diff --git a/protected/src/routes/app/home_routes.php b/protected/src/routes/app/home_routes.php new file mode 100644 index 0000000..c107a4d --- /dev/null +++ b/protected/src/routes/app/home_routes.php @@ -0,0 +1,36 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ + +namespace Project\routes\app; + +use \CodeHydrater\base_controller; + +class home_routes extends base_controller { + /** + * from Routes file + * + */ + public function test(int $id) { + $content = "The ID for Test Example is # $id"; + + $this->response->set_content($content); + return $this->response; + } + + public function demo(?string $name="Test", ?int $limit=10, ?int $page=1) { + $content = "DEMO Name: ". \CodeHydrater\bootstrap\safer_io::p($name); + $content .= "LIMIT = ". $limit; + $content .= "PAGE = ". $page; + + $this->response->set_content($content); + return $this->response; + } + +} \ No newline at end of file diff --git a/protected/src/routes/routes.php b/protected/src/routes/routes.php index a0c62ff..b5b5bf8 100644 --- a/protected/src/routes/routes.php +++ b/protected/src/routes/routes.php @@ -10,8 +10,8 @@ class routes { public static function get() { // ::i is a int() shortcut, ::s is a string - Router::get('example/{id::i}', 'Project\controllers\app\home_ctrl@test'); - Router::route("demo/{name::s}/{limit::i}?/{page::i}?", "Project\controllers\app\home_ctrl@demo"); + Router::get('example/{id::i}', 'Project\routes\app\home_routes@test'); + Router::route('demo/{name::s}/{limit::i}?/{page::i}?', 'Project\routes\app\home_routes@demo'); } } \ No newline at end of file