Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/491c4eda9652a891#
Routing is a way for application decide what content to show based on
provided request data: -
- url
...
- headers
...
- form data
It is implemented in one or another form in all major frameworks, like:
Symphony, Zend Framework.
Right now in 5.1.x and 5.2.0-B3 we have rewrite listeners concept. It's a
method inside event handler class, that knows how to build/parse urls.
There are several problems that needs to be solved in current
implementation: -
- small build/parse methods are located in usually big class (event
...
- handler) and just to build/parse url you create that class instance and eat
...
- lot of memory
...
- no way to create custom url caching key, since rewrite listeners don't
...
- put custom data into caching key
...
- rewrite listeners always create kModRewriteHelper class instance to
...
- use common function for url processing
...
- if you need to pass some custom parameter to rewrite builder to build
...
- a valid link (e.g. filename), then you need to create 2 copies of code
...
- in event handler: to ensure correct link after executing event
...
- on item detail page
...
- in tag processor: to ensure correct link when printing a list
...
- of items
I'm proposing to create base class *kRouter * with these methods: 1.
- build(...) - builds an url
...
- parse(...) - parses an url
...
- getLinkParams($object) - returns extra url parameters, extracted from
...
- object, that are required to successfully build a link
...
- processParams(&$params) - get parameters, associated with given
...
- unit and remove it from global scope (like kModRewriteHelper::getProcessedParams
...
- method now)
...
- patchCachingKey($caching_key) - get caching key as input and return
...
- patched version (allows to put header values into caching key, used to
...
- cache parsed url)
Then in unit config you can register router using this code:
Code Block | ||
---|---|---|
| ||
'RouterClass' => Array ('class' => 'WidgetRouter', 'file' => |
...
'widget_router.php', 'build_event' => 'OnBuild'), |
And class, who right now processes all that stuff called kRewriteProcessor
would kRewriteProcessor would be renamed to kRoutingManager (maybe not a first) to make it all
sound all sound good.
--
Best Regards,
...
Related Tasks
Jira Legacy | ||||
---|---|---|---|---|
|