Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   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   * Contains the content_item class.
  19   *
  20   * @package    core
  21   * @subpackage course
  22   * @copyright  2020 Jake Dallimore <jrhdallimore@gmail.com>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  namespace core_course\local\entity;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * The content_item class.
  31   *
  32   * @copyright  2020 Jake Dallimore <jrhdallimore@gmail.com>
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class content_item {
  36      /** @var int $id the id. */
  37      private $id;
  38  
  39      /** @var string $name the name. */
  40      private $name;
  41  
  42      /** @var title $title the title. */
  43      private $title;
  44  
  45      /** @var \moodle_url $link the url for the content item's setup page (usually mod/edit.php). */
  46      private $link;
  47  
  48      /** @var string $icon an html string containing the icon for this item. */
  49      private $icon;
  50  
  51      /** @var string $help the description/help text for this content item. */
  52      private $help;
  53  
  54      /** @var int $achetype a module archetype, e.g. MOD_ARCHETYPE_RESOURCE, MOD_ARCHETYPE_OTHER. */
  55      private $archetype;
  56  
  57      /** @var string $componentname the name of the component from which this content item originates. */
  58      private $componentname;
  59  
  60      /**
  61       * The content_item constructor.
  62       *
  63       * @param int $id Id number.
  64       * @param string $name Name of the item, not human readable.
  65       * @param title $title Human readable title for the item.
  66       * @param \moodle_url $link The URL to the creation page, with any item specific params
  67       * @param string $icon HTML containing the icon for the item
  68       * @param string $help The description of the item.
  69       * @param int $archetype the archetype for the content item (see MOD_ARCHETYPE_X definitions in lib/moodlelib.php).
  70       * @param string $componentname the name of the component/plugin with which this content item is associated.
  71       */
  72      public function __construct(int $id, string $name, title $title, \moodle_url $link, string $icon, string $help,
  73              int $archetype, string $componentname) {
  74          $this->id = $id;
  75          $this->name = $name;
  76          $this->title = $title;
  77          $this->link = $link;
  78          $this->icon = $icon;
  79          $this->help = $help;
  80          $this->archetype = $archetype;
  81          $this->componentname = $componentname;
  82      }
  83  
  84      /**
  85       * Get the name of the component with which this content item is associated.
  86       *
  87       * @return string
  88       */
  89      public function get_component_name(): string {
  90          return $this->componentname;
  91      }
  92  
  93      /**
  94       * Get the help description of this item.
  95       *
  96       * @return string
  97       */
  98      public function get_help(): string {
  99          return $this->help;
 100      }
 101  
 102      /**
 103       * Get the archetype of this item.
 104       *
 105       * @return int
 106       */
 107      public function get_archetype(): int {
 108          return $this->archetype;
 109      }
 110  
 111      /**
 112       * Get the id of this item.
 113       * @return int
 114       */
 115      public function get_id(): int {
 116          return $this->id;
 117      }
 118  
 119      /**
 120       * Get the name of this item.
 121       *
 122       * @return string
 123       */
 124      public function get_name(): string {
 125          return $this->name;
 126      }
 127  
 128      /**
 129       * Get the human readable title of this item.
 130       *
 131       * @return title
 132       */
 133      public function get_title(): title {
 134          return $this->title;
 135      }
 136  
 137      /**
 138       * Get the link to the creation page of this item.
 139       *
 140       * @return \moodle_url
 141       */
 142      public function get_link(): \moodle_url {
 143          return $this->link;
 144      }
 145  
 146      /**
 147       * Get the icon html for this item.
 148       *
 149       * @return string
 150       */
 151      public function get_icon(): string {
 152          return $this->icon;
 153      }
 154  }