2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * The langimport langpack removed event.
20 * @package tool_langimport
21 * @copyright 2014 Dan Poltawski <dan@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace tool_langimport\event;
27 defined('MOODLE_INTERNAL') || die();
30 * The tool_langimport langpack removed event class.
32 * @property-read array $other {
33 * Extra information about event.
35 * - string langcode: the langpage pack code.
38 * @package tool_langimport
39 * @copyright 2014 Dan Poltawski <dan@moodle.com>
40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42 class langpack_removed extends \core\event\base {
44 * Create instance of event.
46 * @param string $langcode
47 * @return langpack_updated
49 public static function event_with_langcode($langcode) {
51 'context' => \context_system::instance(),
53 'langcode' => $langcode,
57 return self::create($data);
65 protected function init() {
66 $this->data['crud'] = 'd';
67 $this->data['edulevel'] = self::LEVEL_OTHER;
71 * Returns description of what happened.
75 public function get_description() {
76 return "The language pack '{$this->other['langcode']}' was removed.";
80 * Returns relevant URL.
84 public function get_url() {
85 return new \moodle_url('/admin/tool/langimport/');
89 * Return localised event name.
93 public static function get_name() {
94 return get_string('langpackremovedevent', 'tool_langimport');
100 * @throws \coding_exception
102 protected function validate_data() {
103 parent::validate_data();
105 if (!isset($this->other['langcode'])) {
106 throw new \coding_exception('The \'langcode\' value must be set');
109 // We can't use PARAM_LANG here as it queries installed strings.
110 $cleanedlang = clean_param($this->other['langcode'], PARAM_SAFEDIR);
111 if ($cleanedlang !== $this->other['langcode']) {
112 throw new \coding_exception('The \'langcode\' value must be set to a valid language code');