public static function save_category(category_controller $category) {
        $isnewcategory = empty($category->get('id'));

        $category->save();

        if ($isnewcategory) {
            // Move to the end.
            self::move_category($category);
            category_created::create_from_object($category)->trigger();
        } else {
            category_updated::create_from_object($category)->trigger();
        }
    }