Skip to content

Commit d8584e7

Browse files
committed
Add wipe function
1 parent 7176654 commit d8584e7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

classes/manager.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,4 +572,28 @@ public function get_compcatname_for_flavor(string $flavorname): string {
572572
}
573573
return $compcatname ?? '';
574574
}
575+
576+
/**
577+
* This function deletes all data from the plugin tables and from the filesystem.
578+
* Use with caution!
579+
*/
580+
public function wipe(): void {
581+
global $DB;
582+
$DB->delete_records(constants::TABLES['compcat']);
583+
$DB->delete_records(constants::TABLES['component']);
584+
$DB->delete_records(constants::TABLES['flavor']);
585+
$DB->delete_records(constants::TABLES['variant']);
586+
$DB->delete_records(constants::TABLES['comp_flavor']);
587+
$DB->delete_records(constants::TABLES['comp_variant']);
588+
589+
$fs = get_file_storage();
590+
$fs->delete_area_files($this->contextid, 'tiny_elements', 'images');
591+
$fs->delete_area_files($this->contextid, 'tiny_elements', 'export');
592+
593+
// Purge CSS and JS cache.
594+
\tiny_elements\local\utils::purge_css_cache();
595+
\tiny_elements\local\utils::rebuild_css_cache();
596+
\tiny_elements\local\utils::purge_js_cache();
597+
\tiny_elements\local\utils::rebuild_js_cache();
598+
}
575599
}

0 commit comments

Comments
 (0)