Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Discussion summary class.
  19   *
  20   * @package    mod_forum
  21   * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace mod_forum\local\entities;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  use mod_forum\local\entities\discussion as discussion_entity;
  30  use mod_forum\local\entities\post as post_entity;
  31  use mod_forum\local\entities\author as author_entity;
  32  
  33  /**
  34   * Discussion summary class.
  35   *
  36   * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
  37   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  38   */
  39  class discussion_summary {
  40      /** @var discussion_entity $discussion The discussion being summarised */
  41      private $discussion;
  42      /** @var author_entity $firstpostauthor Author of the first post in the discussion */
  43      private $firstpostauthor;
  44      /** @var post_entity $firstpost First post in the discussion */
  45      private $firstpost;
  46      /** @var author_entity $latestpostauthor Author of the last post in the discussion */
  47      private $latestpostauthor;
  48  
  49      /**
  50       * Constructor.
  51       *
  52       * @param discussion_entity $discussion The discussion being summarised
  53       * @param post_entity $firstpost First post in the discussion
  54       * @param author_entity $firstpostauthor Author of the first post in the discussion
  55       * @param author_entity $latestpostauthor Author of the last post in the discussion
  56       */
  57      public function __construct(
  58          discussion_entity $discussion,
  59          post_entity $firstpost,
  60          author_entity $firstpostauthor,
  61          author_entity $latestpostauthor
  62      ) {
  63          $this->discussion = $discussion;
  64          $this->firstpostauthor = $firstpostauthor;
  65          $this->firstpost = $firstpost;
  66          $this->latestpostauthor = $latestpostauthor;
  67      }
  68  
  69      /**
  70       * Get the discussion entity.
  71       *
  72       * @return discussion_entity
  73       */
  74      public function get_discussion() : discussion_entity {
  75          return $this->discussion;
  76      }
  77  
  78      /**
  79       * Get the author entity for the first post.
  80       *
  81       * @return author_entity
  82       */
  83      public function get_first_post_author() : author_entity {
  84          return $this->firstpostauthor;
  85      }
  86  
  87      /**
  88       * Get the author entity for the last post.
  89       *
  90       * @return author_entity
  91       */
  92      public function get_latest_post_author() : author_entity {
  93          return $this->latestpostauthor;
  94      }
  95  
  96      /**
  97       * Get the post entity for the first post.
  98       *
  99       * @return post_entity
 100       */
 101      public function get_first_post() : post_entity {
 102          return $this->firstpost;
 103      }
 104  }