Uh oh!
There was an error while loading. Please reload this page.
feat: add URIFactory - #7239
Conversation
When registering Exception Handler, Request object was generated. But it was too early, and difficult to understand.
baseURL should not be empty.
This class does not work yet.
816dbcc to
516a76aCompare| public function __construct(array &$server, array &$get, App $appConfig) | ||
| { | ||
| $this->server = &$server; | ||
| $this->get = &$get; |
There was a problem hiding this comment.
I don't think passing by reference, which means modifying superglobal arrays, is the right approach.
iRedds
commented
Feb 10, 2023
In my opinion, two factories are needed To create a separate class that works directly with |
kenjis
commented
Feb 10, 2023
How do you create Request object without URI object? |
iRedds
commented
Feb 10, 2023
Say hello to the framework architects for the URI class in the Request constructor. |
kenjis
commented
Feb 10, 2023
Sorry, I don't get what you say at all. |
iRedds
commented
Feb 10, 2023
The URI class depends on the Request class for incoming requests because the Request class must provide access to a copy of _SERVER. Therefore, making the Request class dependent on the URI is a framework architecture error. I don't know who designed these classes. |
kenjis
commented
Feb 10, 2023
Indeed.
Who designed does not matter. |
I don't know.
publicfunction__constructor (protectedarray$query = [], protectedarray$request = [], protectedarray$server = []) {}
// and factorypublicstaticfunctioncreateFromGlobals(): Request {
$request = newstatic($_GET, $_REQUEST, $_SERVER);
return$request->withUri(Uri::createFromRequest($request));
}
if (empty($userAgent)) {
thrownewInvalidArgumentException('You must supply the parameters: uri, userAgent.');
}
$this->uri = $uri ?? URI::createFromRequest($this);Or something similar. |
Needs #7232
Description
Add
URIFactoryto create the current URI object.To create the current URI object before the Request object. Also, to remove all URI adjustment processing currently performed in the constructor of the Request object.
This PR does not change any existing features yet.
URIFactory::createFromGlobals()URI::setRoutePath()andURI::getRoutePath()Checklist: