public function get_export_attachment_url_from_post_and_attachment(post_entity $post, stored_file $attachment) : ?moodle_url {
        global $CFG;

        require_once($CFG->libdir . '/portfoliolib.php');
        $button = new \portfolio_add_button();
        $button->set_callback_options(
            'forum_portfolio_caller',
            ['postid' => $post->get_id(), 'attachment' => $attachment->get_id()],
            'mod_forum'
        );
        $button->set_format_by_file($attachment);
        $url = $button->to_html(PORTFOLIO_ADD_MOODLE_URL);
        return $url ?: null;
    }