Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.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   * Contains class block_rss_client\output\block
  19   *
  20   * @package   block_rss_client
  21   * @copyright 2015 Howard County Public School System
  22   * @author    Brendan Anderson <brendan_anderson@hcpss.org>
  23   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace block_rss_client\output;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  /**
  31   * Class to help display an RSS Feeds block
  32   *
  33   * @package   block_rss_client
  34   * @copyright 2016 Howard County Public School System
  35   * @author    Brendan Anderson <brendan_anderson@hcpss.org>
  36   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class block implements \renderable, \templatable {
  39  
  40      /**
  41       * An array of renderable feeds
  42       *
  43       * @var array
  44       */
  45      protected $feeds;
  46  
  47      /**
  48       * Contruct
  49       *
  50       * @param array $feeds An array of renderable feeds
  51       */
  52      public function __construct(array $feeds = array()) {
  53          $this->feeds = $feeds;
  54      }
  55  
  56      /**
  57       * Prepare data for use in a template
  58       *
  59       * @param \renderer_base $output
  60       * @return array
  61       */
  62      public function export_for_template(\renderer_base $output) {
  63          $data = array('feeds' => array());
  64  
  65          foreach ($this->feeds as $feed) {
  66              $data['feeds'][] = $feed->export_for_template($output);
  67          }
  68  
  69          return $data;
  70      }
  71  
  72      /**
  73       * Add a feed
  74       *
  75       * @param \block_rss_client\output\feed $feed
  76       * @return \block_rss_client\output\block
  77       */
  78      public function add_feed(feed $feed) {
  79          $this->feeds[] = $feed;
  80  
  81          return $this;
  82      }
  83  
  84      /**
  85       * Set the feeds
  86       *
  87       * @param array $feeds
  88       * @return \block_rss_client\output\block
  89       */
  90      public function set_feeds(array $feeds) {
  91          $this->feeds = $feeds;
  92  
  93          return $this;
  94      }
  95  
  96      /**
  97       * Get feeds
  98       *
  99       * @return array
 100       */
 101      public function get_feeds() {
 102          return $this->feeds;
 103      }
 104  }