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.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 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   * Log iterator reader interface.
  19   *
  20   * @package    core
  21   * @copyright  2015 David Monllao
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core\log;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * Log iterator reader interface.
  31   *
  32   * Replaces sql_select_reader adding functions
  33   * to return iterators.
  34   *
  35   * @since      Moodle 2.9
  36   * @package    core
  37   * @copyright  2015 David Monllao
  38   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   */
  40  interface sql_reader extends reader {
  41  
  42      /**
  43       * Fetch records using given criteria.
  44       *
  45       * @param string $selectwhere
  46       * @param array $params
  47       * @param string $sort
  48       * @param int $limitfrom
  49       * @param int $limitnum
  50       * @return \core\event\base[]
  51       */
  52      public function get_events_select($selectwhere, array $params, $sort, $limitfrom, $limitnum);
  53  
  54      /**
  55       * Return number of events matching given criteria.
  56       *
  57       * @param string $selectwhere
  58       * @param array $params
  59       * @return int
  60       */
  61      public function get_events_select_count($selectwhere, array $params);
  62  
  63      /**
  64       * Get whether events are present for the given select clause.
  65       *
  66       * @param string $selectwhere select conditions.
  67       * @param array $params params.
  68       *
  69       * @return bool Whether events available for the given conditions
  70       */
  71      public function get_events_select_exists(string $selectwhere, array $params): bool;
  72  
  73      /**
  74       * Fetch records using the given criteria returning an traversable list of events.
  75       *
  76       * Note that the returned object is Traversable, not Iterator, as we are returning
  77       * EmptyIterator if we know there are no events, and EmptyIterator does not implement
  78       * Countable {@link https://bugs.php.net/bug.php?id=60577} so valid() should be checked
  79       * in any case instead of a count().
  80       *
  81       * Also note that the traversable object contains a recordset and it is very important
  82       * that you close it after using it.
  83       *
  84       * @param string $selectwhere
  85       * @param array $params
  86       * @param string $sort
  87       * @param int $limitfrom
  88       * @param int $limitnum
  89       * @return \Traversable|\core\event\base[] Returns an iterator containing \core\event\base objects.
  90       */
  91      public function get_events_select_iterator($selectwhere, array $params, $sort, $limitfrom, $limitnum);
  92  
  93      /**
  94       * Returns an event from the log data.
  95       *
  96       * @param stdClass $data Log data
  97       * @return \core\event\base
  98       */
  99      public function get_log_event($data);
 100  }