-
Improvement
-
Resolution: Fixed
-
Minor
-
4.0.1
-
MOODLE_400_STABLE
-
MOODLE_401_STABLE
-
MDL-74733-master -
When customising navigation within a plugin, you need to add a class:
mod_yourplugin\local\views\secondary
(The code that does this is in pagelib.php function magic_get_secondarynav and also in blocklib.php get_secondarynav.)
This namespace is not really correct in my opinion, although the definition in https://docs.moodle.org/dev/Coding_style#Rules_for_level2 is not as clear as it could be. My understanding, though, is that:
- mod_yourplugin\local is reserved for custom namespaces that are used/defined only within the current plugin (i.e. for the plugin to organise its own code)
- Code that is used for integrating with core features or APIs should use mod_yourplugin\apiname.
In this case 'navigation' is a core API (see https://moodle.github.io/devdocs/docs/apis) so it should be used in this namespace:
mod_yourplugin\navigation\views\secondary
To fix it without losing backward compatibility, I would suggest that the magic function above should look in the 'navigation' namespace first and then the 'local' one.
We should also move all the existing uses of this class in core modules.