public static function delete_instances_as_record(array $taginstances) {
        global $DB;

        if (empty($taginstances)) {
            return;
        }

        $taginstanceids = array_map(function($taginstance) {
            return $taginstance->id;
        }, $taginstances);
        // Now remove all the tag instances.
        $DB->delete_records_list('tag_instance', 'id', $taginstanceids);
        // Save the system context in case the 'contextid' column in the 'tag_instance' table is null.
        $syscontextid = context_system::instance()->id;
        // Loop through the tag instances and fire an 'tag_removed' event.
        foreach ($taginstances as $taginstance) {
            // We can not fire an event with 'null' as the contextid.
            if (is_null($taginstance->contextid)) {
                $taginstance->contextid = $syscontextid;
            }

            // Trigger tag removed event.
            \core\event\tag_removed::create_from_tag_instance($taginstance, $taginstance->name,
                    $taginstance->rawname, true)->trigger();
        }
    }
public static function delete_instances_as_record(array $taginstances) {
        global $DB;

        if (empty($taginstances)) {
            return;
        }

        $taginstanceids = array_map(function($taginstance) {
            return $taginstance->id;
        }, $taginstances);
        // Now remove all the tag instances.
        $DB->delete_records_list('tag_instance', 'id', $taginstanceids);
        // Save the system context in case the 'contextid' column in the 'tag_instance' table is null.
        $syscontextid = context_system::instance()->id;
        // Loop through the tag instances and fire an 'tag_removed' event.
        foreach ($taginstances as $taginstance) {
            // We can not fire an event with 'null' as the contextid.
            if (is_null($taginstance->contextid)) {
                $taginstance->contextid = $syscontextid;
            }

            // Trigger tag removed event.
            \core\event\tag_removed::create_from_tag_instance($taginstance, $taginstance->name,
                    $taginstance->rawname, true)->trigger();
        }
    }
public static function delete_instances_as_record ( array $ taginstances ) { global $ DB ; if ( empty ( $ taginstances ) ) { return ; } $ taginstanceids = array_map ( function ( $ taginstance ) { return $ taginstance -> id ; } , $ taginstances ) ; // Now remove all the tag instances. $ DB -> delete_records_list ( 'tag_instance' , 'id' , $ taginstanceids ) ; // Save the system context in case the 'contextid' column in the 'tag_instance' table is null. $ syscontextid = context_system :: instance ( ) -> id ; // Loop through the tag instances and fire an 'tag_removed' event. foreach ( $ taginstances as $ taginstance ) { // We can not fire an event with 'null' as the contextid. if ( is_null ( $ taginstance -> contextid ) ) { $ taginstance -> contextid = $ syscontextid ; } // Trigger tag removed event. \ core \ event \ tag_removed :: create_from_tag_instance ( $ taginstance , $ taginstance -> name , $ taginstance -> rawname , true ) -> trigger ( ) ; } }
Bulk delete all tag instances.

@param stdClass[] $taginstances A list of tag_instance records to delete. Each
record must also contain the name and rawname
columns from the related tag record.
Bulk delete all tag instances .