Skip to content

Commit 6b989bf

Browse files
authored
Merge pull request #969 from andrewnicols/communicationApiExampleTidyups
[docs] Tidy up examples to meet coding style
2 parents 5c9b8cc + 686916c commit 6b989bf

File tree

1 file changed

+67
-62
lines changed
  • docs/apis/subsystems/communication

1 file changed

+67
-62
lines changed

docs/apis/subsystems/communication/index.md

+67-62
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ the enabled provider for that instance.
4747

4848
```php
4949
$communication = \core_communication\api::load_by_instance(
50-
context: $context,
51-
component: 'core_course',
52-
instancetype: 'coursecommunication',
53-
instanceid: $courseid,
54-
provider: 'communication_matrix',
55-
);
50+
context: $context,
51+
component: 'core_course',
52+
instancetype: 'coursecommunication',
53+
instanceid: $courseid,
54+
provider: 'communication_matrix',
55+
);
5656
```
5757

5858
### Create and configure a room
@@ -61,10 +61,10 @@ $communication = \core_communication\api::load_by_instance(
6161

6262
```php
6363
public function create_and_configure_room(
64-
string $communicationroomname,
65-
?\stored_file $avatar = null,
66-
?\stdClass $instance = null,
67-
)
64+
string $communicationroomname,
65+
?\stored_file $avatar = null,
66+
?\stdClass $instance = null,
67+
);
6868
```
6969

7070
This method takes the following parameters:
@@ -79,23 +79,27 @@ field named topic which sets the topic of the room, the instance object can be u
7979
Please refer to [Communication plugin](../../plugintypes/communication/index.md) documentation for more details.
8080

8181
```php
82-
// First initialize the communication instance, provided the context is already initialized and the selected provider is available
82+
// First initialize the communication instance,
83+
// provided the context is already initialized
84+
// and the selected provider is available
8385
// though a form or other means.
8486
$communication = \core_communication\api::load_by_instance(
85-
context: $context,
86-
component: 'core_course',
87-
instancetype: 'coursecommunication',
88-
instanceid: $course->id,
89-
provider: 'communication_matrix',
90-
);
91-
92-
// Now call the create_and_configure_room() method to add an ad-hoc to create a room in the communication provider and configure it
93-
// with the required settings.
87+
context: $context,
88+
component: 'core_course',
89+
instancetype: 'coursecommunication',
90+
instanceid: $course->id,
91+
provider: 'communication_matrix',
92+
);
93+
94+
// Now call the create_and_configure_room() method
95+
// to add an ad-hoc to create a room in the
96+
// communication provider and configure it with the
97+
// required settings.
9498
$communication->create_and_configure_room(
95-
communicationroomname: $course->fullname,
96-
avatar: $courseimage ?: null,
97-
instance: $course,
98-
);
99+
communicationroomname: $course->fullname,
100+
avatar: $courseimage ?: null,
101+
instance: $course,
102+
);
99103
```
100104

101105
### Update a room and its associated information
@@ -104,11 +108,11 @@ $communication->create_and_configure_room(
104108

105109
```php
106110
public function update_room(
107-
?int $active = null,
108-
?string $communicationroomname = null,
109-
?\stored_file $avatar = null,
110-
?\stdClass $instance = null,
111-
)
111+
?int $active = null,
112+
?string $communicationroomname = null,
113+
?\stored_file $avatar = null,
114+
?\stdClass $instance = null,
115+
);
112116
```
113117

114118
This method takes the following parameters:
@@ -121,21 +125,22 @@ This method takes the following parameters:
121125
```php
122126
// First initialize the instance.
123127
$communication = \core_communication\api::load_by_instance(
124-
context: $context,
125-
component: 'core_course',
126-
instancetype: 'coursecommunication',
127-
instanceid: $course->id,
128-
provider: 'communication_matrix',
129-
);
130-
131-
// Now update the room with the required settings. The instance will be used by dynamic fields feature of the plugin to allow the plugin
132-
// to get the required information from the instance.
128+
context: $context,
129+
component: 'core_course',
130+
instancetype: 'coursecommunication',
131+
instanceid: $course->id,
132+
provider: 'communication_matrix',
133+
);
134+
135+
// Now update the room with the required settings.
136+
// The instance will be used by dynamic fields feature of the plugin
137+
// to allow the plugin to get the required information from the instance.
133138
$communication->update_room(
134-
active: $active,
135-
communicationroomname: $communicationroomname,
136-
avatar: $courseimage ?: null,
137-
instance: $course,
138-
);
139+
active: $active,
140+
communicationroomname: $communicationroomname,
141+
avatar: $courseimage ?: null,
142+
instance: $course,
143+
);
139144
```
140145

141146
### Delete a room
@@ -156,9 +161,9 @@ the provider room is also stored in the communication_user table for user mappin
156161

157162
```php
158163
public function add_members_to_room(
159-
array $userids,
160-
bool $queue = true,
161-
)
164+
array $userids,
165+
bool $queue = true,
166+
);
162167
```
163168

164169
This method accepts the following parameters:
@@ -169,16 +174,16 @@ This method accepts the following parameters:
169174
```php
170175
// First initialize the instance, provider is not required here, it will initialize the enabled instance.
171176
$communication = \core_communication\api::load_by_instance(
172-
context: $context,
173-
component: 'core_course',
174-
instancetype: 'coursecommunication',
175-
instanceid: $course->id,
176-
);
177+
context: $context,
178+
component: 'core_course',
179+
instancetype: 'coursecommunication',
180+
instanceid: $course->id,
181+
);
177182

178183
// Now add the members.
179184
$communication->add_members_to_room(
180-
userids: $enrolledusers,
181-
);
185+
userids: $enrolledusers,
186+
);
182187
```
183188

184189
### Update the membership of a room
@@ -188,9 +193,9 @@ The user mapping for each of the users are also reset to allow task to update th
188193

189194
```php
190195
public function update_room_membership(
191-
array $userids,
192-
bool $queue = true,
193-
)
196+
array $userids,
197+
bool $queue = true,
198+
);
194199
```
195200

196201
This method accepts the same parameters as the `add_members_to_room()` method and the usage is also the same.
@@ -202,9 +207,9 @@ The users are flagged as deleted in the communication_user table to allow the ta
202207

203208
```php
204209
public function remove_members_from_room(
205-
array $userids,
206-
bool $queue = true
207-
)
210+
array $userids,
211+
bool $queue = true
212+
);
208213
```
209214

210215
This method accepts the same parameters as the `add_members_to_room()` method and the usage is also the same.
@@ -225,9 +230,9 @@ It will also be required to use `set_data()` method in order to set the data to
225230

226231
```php
227232
public function form_definition(
228-
\MoodleQuickForm $mform,
229-
string $selectdefaultcommunication = processor::PROVIDER_NONE,
230-
)
233+
\MoodleQuickForm $mform,
234+
string $selectdefaultcommunication = processor::PROVIDER_NONE,
235+
);
231236
```
232237

233238
This method accepts the following parameters:

0 commit comments

Comments
 (0)