Make Controller::setBasicVariablesView
, Controller::setGeneralVariablesView
etc reusable
#7881
Labels
c: Platform
For Matomo platform changes that aren't impacting any of our APIs but improve the core itself.
wontfix
If you can reproduce this issue, please reopen the issue or create a new one describing it.
Milestone
We have a couple of widgets such as Insights: https://github.com/piwik/piwik/blob/2.13.1/plugins/Insights/Widgets.php#L17
They define the widget in
Widgets.php
but the rendering is done in theController
. This is usually good /ok since this is what a Controller does. But we want plugin developers to do all this in aWidgets.php
or (Widget.php
after #7861 is done). It would be nice to have many good examples in the code base and render the widget actually in the widget class. The pretty much only reason why they are rendered in the controller is because they use egsetBasicVariablesView
: https://github.com/piwik/piwik/blob/2.13.1/plugins/Insights/Controller.php#L51 which won't be available in theWidget
class. Personally, I'd like to avoid people having to use a controller anyway. I rather want them having to use onlyReport
orWidget
or ... which is more meaningful and they don't have to learn about too many classes etc. With a simple example generated by the command line it is fairly easy to create a widget this way. Of course if they want to create a plain page such as a "Help" page or so they will still have to use a Controller.There is eg:
setGeneralVariablesView
: https://github.com/piwik/piwik/blob/2.13.1/core/Plugin/Controller.php#L582setBasicVariablesView
: https://github.com/piwik/piwik/blob/2.13.1/core/Plugin/Controller.php#L687setBasicVariablesAdminView
: https://github.com/piwik/piwik/blob/2.13.1/core/Plugin/ControllerAdmin.php#L167How can we make them more reusable and remove them from Controllers? Eg by decorators?
new GeneralVariablesView(new BasicVariablesView(new View))
? Or shall we extract them into a different class? Which one?This will also help us to solve "Having Controller and ControllerAdmin class is confusing #6151".
Any thoughts? @mattab @diosmosis @mnapoli @sgiehl
The text was updated successfully, but these errors were encountered: