Skip to content

Commit a94a6d5

Browse files
committed
[docs] Describe the new subplugintypes object (MDL-83705)
1 parent dd17877 commit a94a6d5

File tree

2 files changed

+73
-4
lines changed

2 files changed

+73
-4
lines changed

Diff for: docs/devupdate.md

+47
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,50 @@ tags:
88
<!-- markdownlint-disable no-inline-html -->
99

1010
This page highlights the important changes that are coming in Moodle 5.0 for developers.
11+
12+
## Subplugins
13+
14+
<Since version="5.0" issueNumber="MDL-83705" />
15+
16+
The `subplugins.json` file now requires a new `subplugintypes` object to define the subplugins available within a plugin.
17+
18+
The format of this is identical to the existing `plugintypes` object, but the value should be a path which is relative to the plugin's root directory.
19+
20+
:::tip Example of the new `subplugintypes` values
21+
22+
The Quiz Activity located in `mod/quiz` defines the `quizaccess` subplugin type.
23+
24+
The legacy `plugintype` entry for this is as follows:
25+
26+
```json title="mod/quiz/db/subplugins.json demonstrating the legacy plugintypes object"
27+
{
28+
"plugintypes": {
29+
"quizaccess": "mod/quiz/accessrule"
30+
}
31+
}
32+
```
33+
34+
The new `subplugintypes` value is relative to the plugin root as follows:
35+
36+
```json title="mod/quiz/db/subplugins.json demonstrating the new subplugintypes object"
37+
{
38+
"subplugintypes": {
39+
"quizaccess": "accessrule"
40+
}
41+
}
42+
```
43+
44+
Both of these values may be combined for plugins supporting both Moodle 4.5 and earlier, and Moodle 5.0 onwards.
45+
46+
```json title="mod/quiz/db/subplugins.json demonstrating both the legacy plugintypes and the new subplugintypes values"
47+
{
48+
"plugintypes": {
49+
"quizaccess": "mod/quiz/accessrule"
50+
},
51+
"subplugintypes": {
52+
"quizaccess": "accessrule"
53+
}
54+
}
55+
```
56+
57+
:::

Diff for: general/development/tools/metadata/index.md

+26-4
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,43 @@ The name and location on disk of every plugin type, and subsystem is described i
4141

4242
## Subplugins
4343

44-
Any plugin which implements a subplugin must describe its subplugins by name and path in that plugins `db/subplugins.json` location.
44+
Any plugin which supports subplugins must describe its subplugin types by name and path in that plugins `db/subplugins.json` location.
4545

46-
<details>
47-
<summary>Example of a `db/subplugins.json`</summary>
46+
This file requires that subplugins be specified as a set of key and value pairs where the key is the name of the subplugin type, and the value is the path to it.
47+
48+
- The name is the used as a prefix for all namespaces.
49+
- The path is the path that the plugins exist within.
50+
51+
In the following example the subplugins used in `mod_quiz` are described.
52+
53+
The Quiz activity module is located in `mod/quiz`. It has two subplugin types, `quiz`, and `quizaccess` which are located in `mod/quiz/report`, and `mod/quiz/accessrule` respectively.
4854

4955
```json title="mod/quiz/db/subplugins.json"
5056
{
57+
"subplugintypes": {
58+
"quiz": "report",
59+
"quizaccess": "accessrule"
60+
},
5161
"plugintypes": {
5262
"quiz": "mod/quiz/report",
5363
"quizaccess": "mod/quiz/accessrule"
5464
}
5565
}
5666
```
5767

58-
</details>
68+
<Since version="5.0" issueNumber="MDL-83705" />
69+
70+
The list of subplugins should be detailed in the `subplugintypes` object which contains a list of the subplugins where the key is the component type, and the value is the path relative to the parent plugin.
71+
72+
For Moodle versions 4.5 and earlier the `plugintypes` object is used. The same keys must be used, but the values of `subplugintypes` are relative to the plugin's root directory, whilst the value of `plugintypes` are relative to the Moodle project root.
73+
74+
:::danger Plugins supporting Moodle 4.5 and earlier
75+
76+
If your plugin supports subplugins and is intended for use for both Moodle 5.0 and later, and Moodle 4.5 or earlier, you should specify both the `subplugintypes` and the `plugintypes` objects.
77+
78+
When both objects are specified the keys must match, and the paths relative to the plugin must also match.
79+
80+
:::
5981

6082
## APIs
6183

0 commit comments

Comments
 (0)