1441 |
ariadna |
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 |
use core_sms\gateway;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* SMS data generator for tests.
|
|
|
21 |
*
|
|
|
22 |
* @package core_sms
|
|
|
23 |
* @copyright 2024 Safat Shahin <safat.shahin@moodle.com>
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
class core_sms_generator extends component_generator_base {
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Create sms gateway record.
|
|
|
30 |
*
|
|
|
31 |
* @param array $record The gateway record to be created.
|
|
|
32 |
* @return gateway
|
|
|
33 |
*/
|
|
|
34 |
public function create_sms_gateways(array $record): gateway {
|
|
|
35 |
$config = json_decode($record['config'], false, 512, JSON_THROW_ON_ERROR);
|
|
|
36 |
$manager = \core\di::get(\core_sms\manager::class);
|
|
|
37 |
$gateway = $manager->create_gateway_instance(
|
|
|
38 |
classname: $record['classname'],
|
|
|
39 |
name: $record['name'],
|
|
|
40 |
enabled: $record['enabled'],
|
|
|
41 |
config: $config,
|
|
|
42 |
);
|
|
|
43 |
return $gateway;
|
|
|
44 |
}
|
|
|
45 |
}
|