original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Get the url to export attachments for a post.
  
  @param post_entity $post The post
  @param stored_file $attachment
  @return moodle_url|null
docstring_tokens: Get the url to export attachments for a post .