mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-80736 libraries: Move AWS helper code from factor_sms to core\aws
This commit is contained in:
parent
f30110b5eb
commit
2f351c5a8e
@ -16,9 +16,9 @@
|
||||
|
||||
namespace factor_sms\local\smsgateway;
|
||||
|
||||
use factor_sms\admin_settings_aws_region;
|
||||
use core\aws\admin_settings_aws_region;
|
||||
use core\aws\aws_helper;
|
||||
use factor_sms\event\sms_sent;
|
||||
use factor_sms\local\aws_helper;
|
||||
|
||||
/**
|
||||
* AWS SNS SMS Gateway class
|
||||
@ -122,9 +122,6 @@ class aws_sns implements gateway_interface {
|
||||
* @return void
|
||||
*/
|
||||
public static function add_settings(\admin_settingpage $settings): void {
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->dirroot . '/admin/tool/mfa/factor/sms/classes/admin_settings_aws_region.php');
|
||||
$settings->add(new \admin_setting_configcheckbox('factor_sms/usecredchain',
|
||||
get_string('settings:aws:usecredchain', 'factor_sms'), '', 0));
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
/**
|
||||
* Admin setting for AWS regions.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @package core
|
||||
* @author Dmitrii Metelkin <dmitriim@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace factor_sms;
|
||||
namespace core\aws;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@ -32,7 +32,7 @@ require_once($CFG->dirroot . '/lib/adminlib.php');
|
||||
/**
|
||||
* Admin setting for a list of AWS regions.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @package core
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@ -50,7 +50,9 @@ class admin_settings_aws_region extends \admin_setting_configtext {
|
||||
|
||||
$default = $this->get_defaultsetting();
|
||||
$options = [];
|
||||
$all = require_once($CFG->dirroot . '/lib/aws-sdk/src/data/endpoints.json.php');
|
||||
// We do require() not require_once() here, as the file returns a value and we may need to get
|
||||
// this value more than once.
|
||||
$all = require($CFG->dirroot . '/lib/aws-sdk/src/data/endpoints.json.php');
|
||||
$ends = $all['partitions'][0]['regions'];
|
||||
if ($ends) {
|
||||
foreach ($ends as $key => $value) {
|
||||
@ -69,7 +71,7 @@ class admin_settings_aws_region extends \admin_setting_configtext {
|
||||
'size' => $this->size,
|
||||
'options' => $options,
|
||||
];
|
||||
$element = $OUTPUT->render_from_template('factor_sms/setting_aws_region', $context);
|
||||
$element = $OUTPUT->render_from_template('core/aws/setting_aws_region', $context);
|
||||
return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', $default, $query);
|
||||
}
|
||||
}
|
@ -17,13 +17,13 @@
|
||||
/**
|
||||
* AWS helper class. Contains useful functions when interacting with the SDK.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @package core
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace factor_sms\local;
|
||||
namespace core\aws;
|
||||
|
||||
use Aws\CommandInterface;
|
||||
use Aws\AwsClient;
|
@ -17,13 +17,13 @@
|
||||
/**
|
||||
* AWS Client factory. Retrieves a client with moodle specific HTTP configuration.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @package core
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2022 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace factor_sms\local;
|
||||
namespace core\aws;
|
||||
use Aws\AwsClient;
|
||||
|
||||
/**
|
@ -15,7 +15,7 @@
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template factor_sms/setting_aws_region
|
||||
@template core/aws/setting_aws_region
|
||||
|
||||
Admin aws region setting template.
|
||||
|
@ -17,22 +17,22 @@
|
||||
/**
|
||||
* factor_sms unit tests.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @package core
|
||||
* @author Mikhail Golenkov <mikhailgolenkov@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace factor_sms;
|
||||
namespace core\aws;
|
||||
|
||||
/**
|
||||
* Testcase for the list of AWS regions admin setting.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @package core
|
||||
* @author Mikhail Golenkov <mikhailgolenkov@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \admin_settings_aws_region_test
|
||||
* @covers \core\aws\admin_settings_aws_region
|
||||
*/
|
||||
class admin_settings_aws_region_test extends \advanced_testcase {
|
||||
|
@ -15,18 +15,16 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* factor_sms unit tests.
|
||||
* aws_helper unit tests.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @package core
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \factor_sms\local\aws_helper
|
||||
* @covers \core\aws\aws_helper
|
||||
*/
|
||||
|
||||
namespace factor_sms;
|
||||
|
||||
use factor_sms\local\aws_helper;
|
||||
namespace core\aws;
|
||||
|
||||
/**
|
||||
* Testcase for the AWS helper.
|
||||
@ -35,7 +33,7 @@ use factor_sms\local\aws_helper;
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \factor_sms\classes\local\aws_helper
|
||||
* @covers \core\aws\aws_helper
|
||||
*/
|
||||
class aws_helper_test extends \advanced_testcase {
|
||||
|
Loading…
x
Reference in New Issue
Block a user