Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Controller::setBasicVariablesView, Controller::setGeneralVariablesView etc reusable #7881

Closed
tsteur opened this issue May 11, 2015 · 4 comments
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

Comments

@tsteur
Copy link
Member

tsteur commented May 11, 2015

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 the Controller. This is usually good /ok since this is what a Controller does. But we want plugin developers to do all this in a Widgets.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 eg setBasicVariablesView: https://github.com/piwik/piwik/blob/2.13.1/plugins/Insights/Controller.php#L51 which won't be available in the Widget class. Personally, I'd like to avoid people having to use a controller anyway. I rather want them having to use only Report or Widget 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:

How 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

@mattab
Copy link
Member

mattab commented Jul 15, 2015

@tsteur Shall we target this for 3.0.0? It seems required for #7861 which is set for 3.0.0.. thoughts?

@mattab mattab added this to the 3.0.0 milestone Jul 15, 2015
@tsteur
Copy link
Member Author

tsteur commented Jul 15, 2015

We would ideally do this also for #7822 and other issues to have good examples for plugins in our code base. This will help us to move code from controllers into the widget class.

To find a solution we could talk about this in Berlin/Poland. Added a Trello card

@mattab mattab modified the milestones: 3.0.0-b3, 3.0.0 Feb 8, 2016
@mattab mattab modified the milestones: 3.0.0-b3, 3.0.0-b4 Nov 14, 2016
@tsteur
Copy link
Member Author

tsteur commented Nov 23, 2016

Would have been nice to have in 3.0 but not really needed

@mattab mattab modified the milestones: 3.0.0-b4, 4.0.0 Dec 1, 2016
@tsteur
Copy link
Member Author

tsteur commented Feb 11, 2020

Closing this one as I think it isn't really needed anymore. All those methods do is pre-assigning a few view variables. Should the widget need any of these variables, then it is a lot easier to simply assign them as part of the widget render. What variables are assigned in those basic view variables etc is not transparent and not an API anyway.

@tsteur tsteur closed this as completed Feb 11, 2020
@tsteur tsteur added 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. labels Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants