Yes, I think, you should do this in any case.
One alternative might be (depending on your app’s layout), to get rid of the plain (first) route at all. The calendar app is doing something similar (on a deeper level though), see the routes of the calendar app. They allow to route different paths from Vue to the same Controller method.
There are two representations of routes to distinguish:
- in
routes.php
, there is the shorthand contoller#method
to indicate a method to call
- There is a three-dot notation with
app name.controller.route name
.
The three-dot notation is used as the keys in a mapping (according to the docs, not checked in the source code). By default, the three parts can be derived from the app name and the two parts of the router’s method notation (№ 1 above). The values are most probably some internal structure that defines which class and which method to call.
As both routes in question call the very same controller method in the same app, the tree-dot notation is the same. So, you cannot distinguish between the two routes anymore and the linked route in info.xml
is ambiguous.
To solve this, you can alter the three-dot notation by a postfix. (Please do not ask me, what happens if you put a dot there. Probably nothing but unchecked.) Nevertheless, now the mapping in the NC core has two entries that point both to the same controller method. That way you can distinguish the two routes in fact.
So, the internal structure in the core will be something like this (the values are just dummy and not the real game):
$knownRoutes = [
// ...
'workspace.page.index' => [
'Controller' => \OCA\Workspace\Controller\PageConteroller.class,
'method' => 'index'
// ...
],
'workspace.page.indexcatchall' => [
'Controller' => \OCA\Workspace\Controller\PageConteroller.class,
'method' => 'index'
// ...
],
// ...
];
You have now two ways to look at things:
- Given a three-dot notation, what is the corresponding URL? You need this to create the links in the navigation and potentially internally.
- Given the URL (split after
.../apps/workspace
), what controller and what method to use for serving? This is needed for every request to be handled. I guess there is a similar mapping involved to speed up the evaluation but I have not looked it up.
So, the postfix is only to make the three-dot notation unambiguous for further referencing. It does not effect the name of the app, the controller, or the method to use and handle the request.
Does this make it clearer?
Christian