mudrd8mz / moodle-tool_pluginskel

Generator of Moodle plugins skeletons
https://moodle.org/plugins/tool_pluginskel
Other
51 stars 46 forks source link

Supported_features feature #26

Closed alexandru-elisei closed 8 years ago

alexandru-elisei commented 8 years ago

lib.php will be updated with other functions as I generate the rest of the plugin types.

I needed the supports() function for creating the 'backup' feature.

mudrd8mz commented 8 years ago

IIRC, this *_supports() callback is effectively supported by activity modules only. I am wondering what is the plan for the following situation (it comes back again as it was mentioned in our discussions):

alexandru-elisei commented 8 years ago

IIRC, this *_supports() callback is effectively supported by activity modules only.

According to the Backup API blocks, themes and reports all support backup.

Only activity modules need to advertise the fact that they support backup in the moodle2 format?

alexandru-elisei commented 8 years ago

As for the lib.php file, see my comment in #27.

mudrd8mz commented 8 years ago

I know that other plugin types can add their data into the backup file (course formats too, IIRC). What I am saying is that there is no <component>_supports() used in blocks, for example. I think the original intention was to use it, but it never happened.

Only activity modules need to advertise the fact that they support backup in the moodle2 format?

I think so, but I would expect you find this out yourself in the code to be sure. I can't really check these things for you.

mudrd8mz commented 8 years ago

Yes. It is a tricky one. And maybe it will undermine all the current concepts we have. But maybe not, there are surely some ways.

Note that if the generated plugin is an activity module, the function *_supports() should be always generated. Also others like add_instance() and others that are part of the activity module interface. Many of them should be simply generated automatically for any activity module.

Some functions, like navigation callbacks, go also into lib.php and are optional. Such functions should be generated only when these callbacks are specified in the recipe and the given plugin type supports them. Maybe something like

features:
  extend_navigation:
    navigation: true
    settings: true
    user: true
    course: true
    module: true
    user_settings: true

Depending on the plugin type, a skeleton for the corresponding callback would be created. See lib/navigationlib.php for when these callbacks are executed (e.g. any plugin can provide a callback mytype_myname_extend_navigation_user_settings() but not all plugin types can have mytype_myname_extend_settings_navigation().

mudrd8mz commented 8 years ago

Is this valid pull request?

alexandru-elisei commented 8 years ago

Sorry, I am still working on it, forgot to close it. I think I may remove it entirely.