parent
faf188c951
commit
3f0cec856e
@ -0,0 +1,40 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types = 1); |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||||
|
* @copyright (c) 2025, Robert Strutts |
||||||
|
* @license MIT |
||||||
|
*/ |
||||||
|
namespace CodeHydrater; |
||||||
|
|
||||||
|
use \CodeHydrater\http\request as Request; |
||||||
|
use \CodeHydrater\http\response as Response; |
||||||
|
|
||||||
|
/** |
||||||
|
* Description of base_controller |
||||||
|
* |
||||||
|
* To setup child controllers to use request/response, and view/html. |
||||||
|
* |
||||||
|
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||||
|
*/ |
||||||
|
abstract class base_controller { |
||||||
|
|
||||||
|
protected $view; |
||||||
|
protected $html; |
||||||
|
|
||||||
|
public function __construct( |
||||||
|
protected Request $request, |
||||||
|
protected Response $response |
||||||
|
) { |
||||||
|
$this->view = new \CodeHydrater\view(); |
||||||
|
$this->html = new \CodeHydrater\html_document(); |
||||||
|
|
||||||
|
// If the child controller has an init() method, call it automatically |
||||||
|
if (method_exists($this, 'init')) { |
||||||
|
$this->init(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types = 1); |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||||
|
* @copyright (c) 2025, Robert Strutts |
||||||
|
* @license MIT |
||||||
|
*/ |
||||||
|
namespace CodeHydrater\enums; |
||||||
|
|
||||||
|
enum exit_on_dump: int { |
||||||
|
case exit_and_stop = 0; |
||||||
|
case keep_working = 1; |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types = 1); |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||||
|
* @copyright (c) 2025, Robert Strutts |
||||||
|
* @license MIT |
||||||
|
*/ |
||||||
|
namespace CodeHydrater; |
||||||
|
|
||||||
|
/** |
||||||
|
* Description of parameter_bag |
||||||
|
* Used by: http/request |
||||||
|
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||||
|
*/ |
||||||
|
class parameter_bag { |
||||||
|
public function __construct(private array $parameters = []) { } |
||||||
|
|
||||||
|
public function get($key, $default = null) { |
||||||
|
return $this->parameters[$key] ?? $default; |
||||||
|
} |
||||||
|
|
||||||
|
public function has($key) { |
||||||
|
return array_key_exists($key, $this->parameters); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue