| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | declare(strict_types=1); |
|---|
| 4 | |
|---|
| 5 | require(dirname(__DIR__) . '/bootstrap.php'); |
|---|
| 6 | |
|---|
| 7 | use App\Form\LoginForm; |
|---|
| 8 | use App\Form\RegistrationForm; |
|---|
| 9 | use App\View\DemoPage; |
|---|
| 10 | use App\View\LoginPage; |
|---|
| 11 | use App\View\RegistrationPage; |
|---|
| 12 | use App\View\Redirect; |
|---|
| 13 | use App\View\ErrorPage; |
|---|
| 14 | use App\View\DebugExceptionPage; |
|---|
| 15 | use App\View\DebugShowSourcePage; |
|---|
| 16 | |
|---|
| 17 | try { |
|---|
| 18 | (match($_REQUEST['action'] ?? 'index') { |
|---|
| 19 | default => new DemoPage(), |
|---|
| 20 | 'login' => new LoginPage(), |
|---|
| 21 | 'login_error' => (function (): LoginPage { |
|---|
| 22 | $page = new LoginPage(); |
|---|
| 23 | $page->form = new LoginForm(); |
|---|
| 24 | $page->form->hasError = true; |
|---|
| 25 | $page->form->login = 'admin'; |
|---|
| 26 | $page->form->password = '123456'; |
|---|
| 27 | return $page; |
|---|
| 28 | })(), |
|---|
| 29 | 'register' => new RegistrationPage(), |
|---|
| 30 | 'redirect' => (function (): Redirect { |
|---|
| 31 | $page = new Redirect('https://example.com/'); |
|---|
| 32 | $page->headers = []; |
|---|
| 33 | return $page; |
|---|
| 34 | })(), |
|---|
| 35 | 'error' => new ErrorPage(), |
|---|
| 36 | 'exception' => (function () { |
|---|
| 37 | throw new RuntimeException('Hi there'); |
|---|
| 38 | })(), |
|---|
| 39 | 'source' => new DebugShowSourcePage(__FILE__), |
|---|
| 40 | })->render(); |
|---|
| 41 | } catch (Exception|Error $e) { |
|---|
| 42 | new DebugExceptionPage($e)->render(); |
|---|
| 43 | } |
|---|
| 44 | |
|---|