Skip to content

Change Widgets API for plugins #7861

@tsteur

Description

@tsteur

While working on #7822 I noticed that it makes sense to change the Widgets API.

This is how we currently define a Widget: http://developer.piwik.org/guides/widgets
It was one of the first APIs that we revised and it works fine and is easy to use. Though it makes sense to refactor it with some features in mind etc. (#7822, #7131, #4734).

  • I'm pretty sure we will be able to maintain BC, we could break the API for Piwik 3.0.0
  • We possibly will be able to convert code from old logic to new logic automatically
  • Reports share a lot of similarities with Widgets (name, category, module, action, render, ...) and Reports are more or less widgets, they could implement the same interface or extend each other or ...
  • The code generator will allow us to generate specific widgets (this is currently not the case as we'd have to manipulate an existing widget class)
  • We will be later able to add widgets to a page in the UI (if wanted)
  • If there are many dependencies because there are many different widgets we will have less dependencies when having one class per widget
  • Types/Properties (refs Add possibility to manage and view Apps #7131 and Build a generic Analytics platform: allow to measure 'Mobile App', 'Intranet Website', 'Wearable', 'Sensor' and more #4734) will be able to rename widgets, to remove them, etc.
  • We could later allow plugins to overwrite existing widgets (not important, just saying would be possible)
  • We can give widgets an order
  • We can generate translation keys automatically
  • We might have in soon another "thing" beside Reports and Widgets related to ReportsByDimension (ignore it for now)

The API itself will look similar to a Report I reckon.

  • We will have all widgets in a directory Widgets
  • A widget will be named by the action similar to reports eg Widgets\GetDonateForm.php

TODO:

  • What about Widgets::configureWidgetsList(), shall we call this in each Widget itself?

Metadata

Metadata

Assignees

Labels

TaskIndicates an issue is neither a feature nor a bug and it's purely a "technical" change.c: PlatformFor Matomo platform changes that aren't impacting any of our APIs but improve the core itself.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions