Feature Request #2529
HMVC request with array values
| Status: | Closed | Start date: | 02/01/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | Core | |||
| Target version: | - | |||
| Resolution: | wontfix | Points: |
Description
Currently, I must use something like this:
echo Request->factory($this->request->uri(array('controller' => 'test', 'action' => 'test', 'id' => 1)))->execute();
So at first we build uri from request params, and further parse it anew. I suggest to add possibility to pass uri params directly:
echo Request->factory(array('route' => 'test', 'controller' => 'test', 'action' => 'test', 'id' => 1))->execute();
[NOTE] if route name is not set, use current route.
History
Updated by Bence Eros over 2 years ago
I think if you do it this way:
echo Request->factory(array('route' => 'test', 'controller' => 'test', 'action' => 'test', 'id' => 1))->execute();then you don't have to pass the route (the route defines a method to get the controller, action and params from the request uri - why to pass the route if you pass these values directly and not encoded in a string?)
Updated by Ivan Brotkin over 2 years ago
For example, some links in request's response will be generated by $this->request->uri(). Anyway, any request should know about its route ;)
Updated by Ivan Brotkin over 2 years ago
I disagree. This way you will always use current route (Request::instance()->route). Thats why I suggest to add 'route' param.
Updated by Bence Eros over 2 years ago
- File request.patch added
Ok, I agree, you are true. What about this version?
Updated by Ivan Brotkin over 2 years ago
Well, it will be perfect, if Route has something like get_default($segment) to get default value. I think, its not good to throw an Exception if one of the (controller|action|route) was not set. As we have default route and default values - we should use it. I think, Ko3 requires get_default() for this feature.
Updated by Bence Eros over 2 years ago
If by default route you mean the route with key 'default' then this feature is easy to implement.
Otherwise I looked around the routing and I think Route::$default_action doesn't make sense. It is only used by request.php at line 865, and it is a default if the route didn't provide any action. In other words it is a default for the case when in bootstrap.php you don't define the default action. I don't think this make sense, especially while the controller hasn't got a default like this.
Updated by Ivan Brotkin over 2 years ago
No, default route is a current route (Request::instance()->route). And I dont want to use Route::$default_action. All we need is a special method (I named it get_default($segment)). For example:
if ( ! (array_key_exists('route', $uri) ) )
{
$this->route = Request::instance()->route;
}
if ( ! (array_key_exists('controller', $uri) ) )
{
$this->controller = $route->get_default('controller');
}
// etc.
There is one problem - Request object has $uri property and we should fill it (call $this->route->uri() anyway?). As HMVC calls don't (usually) use $this->request->uri, it can be "lazy loaded". But is it wat we need?..
Updated by Alexandr Karpinsky about 2 years ago
$uri not required contain 'controller' or 'action' if it already in defaults.
Look at my old implementation:
http://homm.stratero.ru/pages/exrequest.zip
Kohana request don't check, if controller exists, and you shouldn't.
Route must return defaults (now it not) and then we can it simple:
http://pastie.org/875026
Updated by Jeremy Bush over 1 year ago
- Target version changed from v3.1.0 to v3.2.0
Updated by Jeremy Bush 12 months ago
- Target version changed from v3.2.0 to v3.3.0
I'm not sure what the point of this issue is. Requests need a string URI to process. It can't and shouldn't take an array.
Updated by Jeremy Bush 5 months ago
- Target version changed from v3.3.0 to Unscheduled
Updated by Woody Gilk 4 months ago
- Status changed from New to Closed
- Assignee set to Woody Gilk
- Target version deleted (
Unscheduled) - Resolution set to wontfix