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.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 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      /** @var string $purpose the purpose type of this component. */
  61      private $purpose;
  62  
  63      /**
  64       * The content_item constructor.
  65       *
  66       * @param int $id Id number.
  67       * @param string $name Name of the item, not human readable.
  68       * @param title $title Human readable title for the item.
  69       * @param \moodle_url $link The URL to the creation page, with any item specific params
  70       * @param string $icon HTML containing the icon for the item
  71       * @param string $help The description of the item.
  72       * @param int $archetype the archetype for the content item (see MOD_ARCHETYPE_X definitions in lib/moodlelib.php).
  73       * @param string $componentname the name of the component/plugin with which this content item is associated.
  74       * @param string $purpose the purpose type of this component.
  75       */
  76      public function __construct(int $id, string $name, title $title, \moodle_url $link, string $icon, string $help,
  77              int $archetype, string $componentname, string $purpose) {
  78          $this->id = $id;
  79          $this->name = $name;
  80          $this->title = $title;
  81          $this->link = $link;
  82          $this->icon = $icon;
  83          $this->help = $help;
  84          $this->archetype = $archetype;
  85          $this->componentname = $componentname;
  86          $this->purpose = $purpose;
  87      }
  88  
  89      /**
  90       * Get the name of the component with which this content item is associated.
  91       *
  92       * @return string
  93       */
  94      public function get_component_name(): string {
  95          return $this->componentname;
  96      }
  97  
  98      /**
  99       * Get the help description of this item.
 100       *
 101       * @return string
 102       */
 103      public function get_help(): string {
 104          return $this->help;
 105      }
 106  
 107      /**
 108       * Get the archetype of this item.
 109       *
 110       * @return int
 111       */
 112      public function get_archetype(): int {
 113          return $this->archetype;
 114      }
 115  
 116      /**
 117       * Get the id of this item.
 118       * @return int
 119       */
 120      public function get_id(): int {
 121          return $this->id;
 122      }
 123  
 124      /**
 125       * Get the name of this item.
 126       *
 127       * @return string
 128       */
 129      public function get_name(): string {
 130          return $this->name;
 131      }
 132  
 133      /**
 134       * Get the human readable title of this item.
 135       *
 136       * @return title
 137       */
 138      public function get_title(): title {
 139          return $this->title;
 140      }
 141  
 142      /**
 143       * Get the link to the creation page of this item.
 144       *
 145       * @return \moodle_url
 146       */
 147      public function get_link(): \moodle_url {
 148          return $this->link;
 149      }
 150  
 151      /**
 152       * Get the icon html for this item.
 153       *
 154       * @return string
 155       */
 156      public function get_icon(): string {
 157          return $this->icon;
 158      }
 159  
 160      /**
 161       * Get purpose for this item.
 162       *
 163       * @return string
 164       */
 165      public function get_purpose(): string {
 166          return $this->purpose;
 167      }
 168  }