1 |
efrain |
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 |
namespace media_videojs\external;
|
|
|
18 |
|
|
|
19 |
use core_external\external_api;
|
|
|
20 |
use core_external\external_function_parameters;
|
|
|
21 |
use core_external\external_value;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* The API to get language strings for the videojs.
|
|
|
25 |
*
|
|
|
26 |
* @package media_videojs
|
|
|
27 |
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
*/
|
|
|
30 |
class get_language extends external_api {
|
|
|
31 |
/**
|
|
|
32 |
* Returns description of parameters.
|
|
|
33 |
*
|
|
|
34 |
* @return external_function_parameters
|
|
|
35 |
*/
|
|
|
36 |
public static function execute_parameters() {
|
|
|
37 |
return new external_function_parameters([
|
|
|
38 |
'lang' => new external_value(PARAM_ALPHAEXT, 'language')
|
|
|
39 |
]);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Returns language strings in the JSON format
|
|
|
44 |
*
|
|
|
45 |
* @param string $lang The language code
|
|
|
46 |
* @return string
|
|
|
47 |
*/
|
|
|
48 |
public static function execute(string $lang) {
|
|
|
49 |
[
|
|
|
50 |
'lang' => $lang,
|
|
|
51 |
] = external_api::validate_parameters(self::execute_parameters(), [
|
|
|
52 |
'lang' => $lang,
|
|
|
53 |
]);
|
|
|
54 |
|
|
|
55 |
return \media_videojs_plugin::get_language_content($lang);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Returns description of method result value
|
|
|
60 |
*
|
|
|
61 |
* @return external_value
|
|
|
62 |
*/
|
|
|
63 |
public static function execute_returns() {
|
|
|
64 |
return new external_value(PARAM_RAW, 'language pack json');
|
|
|
65 |
}
|
|
|
66 |
}
|