mudrd8mz / moodle-tool_pluginskel

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

Incorrectly named lib.php functions when generating mod_* plugin? #94

Closed leoauri closed 5 years ago

leoauri commented 5 years ago

I added component: mod_room to the recipe (following the auth_test example).

The lib.php file got generated with functions named

mod_room_supports()
mod_room_add_instance()

and so on. But moodle seems to expect these hooks without the mod_ prefix and throws errors.
Is this a bug, or did I create the recipe incorrectly?

leoauri commented 5 years ago

Similarly in db/install.php

mudrd8mz commented 5 years ago

Are you using the latest version? This seems related to what was fixed in #90

mudrd8mz commented 5 years ago

No, you seem to be right - the templates seem to contain {{component}} where they should have {{component_name}}

leoauri commented 5 years ago

I think the lines like $id = $DB->insert_record('{{ component }}', $moduleinstance); are similarly affected.

leoauri commented 5 years ago

Similarly lines 37 and 39 of view.php. Also on line 43 get_string('missingidandcmid', mod_room) is missing quotes. I'll make a PR!

leoauri commented 5 years ago

db_upgrade.mustachedefines

function xmldb_{{^ component_type_is_mod }}{{ component_type }}_{{/ component_type_is_mod }}{{ component_name }}_upgrade

I guess the same should be done in db_install.mustache and db_uninstall.mustache?

mudrd8mz commented 5 years ago

It turned out the unit tests for these things were wrong. I just fixed them in 3783b765ec9e37cd143b410f5a16a856ad72baa3