source: moodle/trunk/fuentes/lib/classes/event/webservice_function_called.php @ 1331

Last change on this file since 1331 was 1331, checked in by jrpelegrina, 3 years ago

Updated to moodle 3.0.3

File size: 2.8 KB
Line 
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 * Web service function called event.
19 *
20 * @package    core
21 * @copyright  2013 Frédéric Massart
22 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25namespace core\event;
26defined('MOODLE_INTERNAL') || die();
27
28/**
29 * Web service function called event class.
30 *
31 * @property-read array $other {
32 *      Extra information about event.
33 *
34 *      - string function: name of the function.
35 * }
36 *
37 * @package    core
38 * @since      Moodle 2.6
39 * @copyright  2013 Frédéric Massart
40 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41 */
42class webservice_function_called extends base {
43
44    /**
45     * Legacy log data.
46     */
47    protected $legacylogdata;
48
49    /**
50     * Returns description of what happened.
51     *
52     * @return string
53     */
54    public function get_description() {
55        return "The web service function '{$this->other['function']}' has been called.";
56    }
57
58    /**
59     * Return the legacy event log data.
60     *
61     * @return array|null
62     */
63    protected function get_legacy_logdata() {
64        return $this->legacylogdata;
65    }
66
67    /**
68     * Return localised event name.
69     *
70     * @return string
71     */
72    public static function get_name() {
73        return get_string('eventwebservicefunctioncalled', 'webservice');
74    }
75
76    /**
77     * Init method.
78     *
79     * @return void
80     */
81    protected function init() {
82        $this->data['crud'] = 'r';
83        $this->data['edulevel'] = self::LEVEL_OTHER;
84        $this->context = \context_system::instance();
85    }
86
87    /**
88     * Return the legacy event log data.
89     *
90     * @param array $legacydata the legacy data to set
91     */
92    public function set_legacy_logdata($legacydata) {
93        $this->legacylogdata = $legacydata;
94    }
95
96    /**
97     * Custom validation.
98     *
99     * @throws \coding_exception
100     * @return void
101     */
102    protected function validate_data() {
103        parent::validate_data();
104        if (!isset($this->other['function'])) {
105           throw new \coding_exception('The \'function\' value must be set in other.');
106        }
107    }
108
109    public static function get_other_mapping() {
110        return false;
111    }
112}
Note: See TracBrowser for help on using the repository browser.