original_string: private function export_attachments(array $attachments, post_entity $post, renderer_base $output, bool $canexport) : array {
          global $CFG;
  
          $urlfactory = $this->related['urlfactory'];
          $enableplagiarism = $CFG->enableplagiarism;
          $forum = $this->related['forum'];
          $context = $this->related['context'];
  
          if ($enableplagiarism) {
              require_once($CFG->libdir . '/plagiarismlib.php' );
          }
  
          return array_map(function($attachment) use (
              $output,
              $enableplagiarism,
              $canexport,
              $context,
              $forum,
              $post,
              $urlfactory
          ) {
              $exporter = new stored_file_exporter($attachment, ['context' => $context]);
              $exportedattachment = $exporter->export($output);
              $exporturl = $canexport ? $urlfactory->get_export_attachment_url_from_post_and_attachment($post, $attachment) : null;
  
              if ($enableplagiarism) {
                  $plagiarismhtml = plagiarism_get_links([
                      'userid' => $post->get_author_id(),
                      'file' => $attachment,
                      'cmid' => $forum->get_course_module_record()->id,
                      'course' => $forum->get_course_id(),
                      'forum' => $forum->get_id()
                  ]);
              } else {
                  $plagiarismhtml = null;
              }
  
              $exportedattachment->urls = [
                  'export' => $exporturl ? $exporturl->out(false) : null
              ];
              $exportedattachment->html = [
                  'plagiarism' => $plagiarismhtml
              ];
  
              return $exportedattachment;
          }, $attachments);
      }
code: private function export_attachments(array $attachments, post_entity $post, renderer_base $output, bool $canexport) : array {
          global $CFG;
  
          $urlfactory = $this->related['urlfactory'];
          $enableplagiarism = $CFG->enableplagiarism;
          $forum = $this->related['forum'];
          $context = $this->related['context'];
  
          if ($enableplagiarism) {
              require_once($CFG->libdir . '/plagiarismlib.php' );
          }
  
          return array_map(function($attachment) use (
              $output,
              $enableplagiarism,
              $canexport,
              $context,
              $forum,
              $post,
              $urlfactory
          ) {
              $exporter = new stored_file_exporter($attachment, ['context' => $context]);
              $exportedattachment = $exporter->export($output);
              $exporturl = $canexport ? $urlfactory->get_export_attachment_url_from_post_and_attachment($post, $attachment) : null;
  
              if ($enableplagiarism) {
                  $plagiarismhtml = plagiarism_get_links([
                      'userid' => $post->get_author_id(),
                      'file' => $attachment,
                      'cmid' => $forum->get_course_module_record()->id,
                      'course' => $forum->get_course_id(),
                      'forum' => $forum->get_id()
                  ]);
              } else {
                  $plagiarismhtml = null;
              }
  
              $exportedattachment->urls = [
                  'export' => $exporturl ? $exporturl->out(false) : null
              ];
              $exportedattachment->html = [
                  'plagiarism' => $plagiarismhtml
              ];
  
              return $exportedattachment;
          }, $attachments);
      }
code_tokens: private function export_attachments ( array $ attachments , post_entity $ post , renderer_base $ output , bool $ canexport ) : array { global $ CFG ; $ urlfactory = $ this -> related [ 'urlfactory' ] ; $ enableplagiarism = $ CFG -> enableplagiarism ; $ forum = $ this -> related [ 'forum' ] ; $ context = $ this -> related [ 'context' ] ; if ( $ enableplagiarism ) { require_once ( $ CFG -> libdir . '/plagiarismlib.php' ) ; } return array_map ( function ( $ attachment ) use ( $ output , $ enableplagiarism , $ canexport , $ context , $ forum , $ post , $ urlfactory ) { $ exporter = new stored_file_exporter ( $ attachment , [ 'context' => $ context ] ) ; $ exportedattachment = $ exporter -> export ( $ output ) ; $ exporturl = $ canexport ? $ urlfactory -> get_export_attachment_url_from_post_and_attachment ( $ post , $ attachment ) : null ; if ( $ enableplagiarism ) { $ plagiarismhtml = plagiarism_get_links ( [ 'userid' => $ post -> get_author_id ( ) , 'file' => $ attachment , 'cmid' => $ forum -> get_course_module_record ( ) -> id , 'course' => $ forum -> get_course_id ( ) , 'forum' => $ forum -> get_id ( ) ] ) ; } else { $ plagiarismhtml = null ; } $ exportedattachment -> urls = [ 'export' => $ exporturl ? $ exporturl -> out ( false ) : null ] ; $ exportedattachment -> html = [ 'plagiarism' => $ plagiarismhtml ] ; return $ exportedattachment ; } , $ attachments ) ; }
docstring: Get the exported attachments for a post.
  
  @param stored_file[] $attachments The list of attachments for the post
  @param post_entity $post The post being exported
  @param renderer_base $output Renderer base
  @param bool $canexport If the user can export the post (relates to portfolios not exporters like this class)
  @return array
docstring_tokens: Get the exported attachments for a post .