Skip to content

Commit a292f9a

Browse files
committed
wip: plan v5 dispatch flow
1 parent 18ff78e commit a292f9a

File tree

3 files changed

+22
-36
lines changed

3 files changed

+22
-36
lines changed

src/Application.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
use GT\WebEngine\Redirection\Redirect;
1010
use GT\WebEngine\Dispatch\Dispatcher;
1111
use GT\WebEngine\Dispatch\DispatcherFactory;
12-
use Gt\Config\Config;
13-
use Gt\Config\ConfigFactory;
14-
use Gt\Http\RequestFactory;
15-
use Gt\Http\Response;
16-
use Gt\Http\ServerRequest;
17-
use Gt\Http\Stream;
18-
use Gt\ProtectedGlobal\Protection;
12+
use GT\Config\Config;
13+
use GT\Config\ConfigFactory;
14+
use GT\Http\RequestFactory;
15+
use GT\Http\Response;
16+
use GT\Http\ServerRequest;
17+
use GT\Http\Stream;
18+
use GT\ProtectedGlobal\Protection;
1919

2020
/**
2121
* The fundamental purpose of any PHP framework is to provide a mechanism for
@@ -95,10 +95,7 @@ public function start():void {
9595
$this->dispatcher = $this->dispatcherFactory->create(
9696
$this->config,
9797
$request,
98-
$this->globals["_GET"],
99-
$this->globals["_POST"],
100-
$this->globals["_FILES"],
101-
$this->globals["_SERVER"],
98+
$this->globals,
10299
);
103100

104101
try {

src/Dispatch/Dispatcher.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
<?php
22
namespace GT\WebEngine\Dispatch;
33

4-
use Gt\Config\Config;
5-
use Gt\Http\Request;
4+
use GT\Config\Config;
5+
use GT\Http\Request;
66
use GT\Http\Response;
7+
use Gt\WebEngine\Logic\AppAutoloader;
78
use Throwable;
89

910
readonly class Dispatcher {
1011
/**
11-
* @param array<string, mixed> $globalGet
12-
* @param array<string, mixed> $globalPost
13-
* @param array<string, mixed> $globalFiles
14-
* @param array<string, mixed> $globalServer
12+
* @param array<string, array<string, string|array<string, string>>> $globals
1513
*/
1614
public function __construct(
1715
private Config $config,
1816
private Request $request,
19-
protected array $globalGet,
20-
protected array $globalPost,
21-
protected array $globalFiles,
22-
protected array $globalServer,
23-
) {}
17+
private array $globals,
18+
AppAutoloader $appAutoloader,
19+
LogicStreamHandler $logicStreamHandler,
20+
) {
21+
}
2422

2523
public function generateResponse():Response {
2624
return new Response(request: $this->request);

src/Dispatch/DispatcherFactory.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
<?php
22
namespace GT\WebEngine\Dispatch;
33

4-
use Gt\Config\Config;
5-
use Gt\Http\Request;
4+
use GT\Config\Config;
5+
use GT\Http\Request;
66

77
class DispatcherFactory {
88
/**
9-
* @param array<string, mixed> $globalGet
10-
* @param array<string, mixed> $globalPost
11-
* @param array<string, mixed> $globalFiles
12-
* @param array<string, mixed> $globalServer
9+
* @param array<string, array<string, string|array<string, string>>> $globals
1310
*/
1411
public function create(
1512
Config $config,
1613
Request $request,
17-
array $globalGet,
18-
array $globalPost,
19-
array $globalFiles,
20-
array $globalServer,
14+
array $globals
2115
):Dispatcher {
2216
return new Dispatcher(
2317
$config,
2418
$request,
25-
$globalGet,
26-
$globalPost,
27-
$globalFiles,
28-
$globalServer,
19+
$globals
2920
);
3021
}
3122
}

0 commit comments

Comments
 (0)