1
1
<?php
2
+ // This file is part of Moodle - http://moodle.org/
3
+ //
4
+ // Moodle is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+ //
9
+ // Moodle is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU General Public License for more details.
13
+ //
14
+ // You should have received a copy of the GNU General Public License
15
+ // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
2
16
3
17
namespace tool_objectfs \task ;
4
18
5
19
use core \task \manager ;
6
20
use core \task \scheduled_task ;
7
21
use tool_objectfs \local \tag \tag_manager ;
8
22
23
+ /**
24
+ * Queues objects needing tag syncing for tag syncing using an adhoc task.
25
+ *
26
+ * @package tool_objectfs
27
+ * @author Matthew Hilton <[email protected] >
28
+ * @copyright Catalyst IT
29
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
+ */
9
31
class queue_objects_needing_tags extends scheduled_task {
10
- public function get_name () {
11
- return get_string ('task:queueobjectsneedingtags ' , 'tool_objectfs ' );
12
- }
32
+ /**
33
+ * Get name
34
+ * @return string
35
+ */
36
+ public function get_name () {
37
+ return get_string ('task:queueobjectsneedingtags ' , 'tool_objectfs ' );
38
+ }
13
39
14
- public function execute () {
15
- if (!tag_manager::is_tagging_enabled_and_supported ()) {
16
- mtrace ("Tagging feature not available or supported, ignoring. " );
17
- return ;
18
- }
40
+ /**
41
+ * Execute task
42
+ */
43
+ public function execute () {
44
+ if (!tag_manager::is_tagging_enabled_and_supported ()) {
45
+ mtrace ("Tagging feature not available or supported, ignoring. " );
46
+ return ;
47
+ }
19
48
20
- // TODO configurable limit per run.
21
- $ contenthashes = tag_manager::get_objects_needing_sync (1000 );
22
- mtrace ("Found " . count ($ contenthashes ) . " objects needing tag sync " );
49
+ // TODO configurable limit per run.
50
+ $ contenthashes = tag_manager::get_objects_needing_sync (1000 );
51
+ mtrace ("Found " . count ($ contenthashes ) . " objects needing tag sync " );
23
52
24
- foreach ($ contenthashes as $ contenthash ) {
25
- $ task = new update_object_tags ();
26
- $ task ->set_custom_data ([
27
- 'contenthash ' => $ contenthash
28
- ]);
29
- manager::queue_adhoc_task ($ task , true );
30
- }
31
- }
53
+ foreach ($ contenthashes as $ contenthash ) {
54
+ $ task = new update_object_tags ();
55
+ $ task ->set_custom_data ([
56
+ 'contenthash ' => $ contenthash
57
+ ]);
58
+ manager::queue_adhoc_task ($ task , true );
59
+ }
60
+ }
32
61
}
0 commit comments