User tests: Successful: Unsuccessful:
Set the $_router
variable as protected instead of private in the class: Joomla\CMS\Router\Route
By doing that we can extend the Route class and define our own Router in that.
This way we can provide additional functionalities in our Router.
It can only be tested by extending the Joomla\CMS\Router\Route
and defining our own Router
No Router can be defined in sub-classes.
You can define your own Router in sub-classes.
DKN
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Title |
|
@HLeithner In my case i want to override the Router::createUri, in order to encode the special characters included in the url's query vars.
But i think that can be used in a more broad way e.g. set validation and escape rules.
Maybe I'm wrong but wouldn't it be easier to add a preprocessor?
@HLeithner Thanks for the suggestion.
Any idea on how this can be implemented?
Create a plugin and add a buildRule in the onAfterInitialise event. somehing like this:
class plgSystemMyRouterExtgension extends JPlugin {
public function onAfterInitialise() {
$app = JFactory::getApplication();
if ($app->isSite()) {
$router = $app->getRouter();
// attach build rules for translation on SEF
$router->attachBuildRule(array($this, 'buildRule'), JRouter::PROCESS_BEFORE);
}
}
public function buildRule(&$router, &$uri) {
/* modify $uri here */
}
}
@HLeithner Thank you!
The actual problem is in the Uri class, hence it requires more than adding rules.
In any case i think that providing the ability to set our own Router could add extra flexibility.
Can you send me the code you want to use in your router if this variable is not private?
@dgrammatiko Valid. The only reason i don't like that, is that is sets an object in the container which will be used globally. I prefer having something with limited scope. But i understand the point that the same class should be used on input and output (build/parse).
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-11-06 15:08:36 |
Closed_By | ⇒ | sakiss | |
Labels |
Added:
Information Required
?
|
Can you give me an example what you want to achieve?