Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
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/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea -...
16
 
-
 
17
/**
-
 
18
 * AWS helper class. Contains useful functions when interacting with the SDK.
-
 
19
 *
-
 
20
 * @package    core
-
 
21
 * @author     Peter Burnett <peterburnett@catalyst-au.net>
-
 
22
 * @copyright  2020 Catalyst IT
-
 
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
24
 */
-
 
25
 
16
 
Línea 26... Línea 17...
26
namespace core\aws;
17
namespace core\aws;
27
 
18
 
28
use Aws\CommandInterface;
19
use Aws\CommandInterface;
Línea 32... Línea 23...
32
/**
23
/**
33
 * This class contains functions that help plugins to interact with the AWS SDK.
24
 * This class contains functions that help plugins to interact with the AWS SDK.
34
 *
25
 *
35
 * @copyright  2020 Catalyst IT
26
 * @copyright  2020 Catalyst IT
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
28
 * @deprecated Since Moodle 4.5
-
 
29
 * @todo       MDL-82459 Final deprecation in Moodle 5.0.
37
 */
30
 */
38
class aws_helper {
31
class aws_helper {
Línea 39... Línea 32...
39
 
32
 
40
    /**
33
    /**
41
     * This creates a proxy string suitable for use with the AWS SDK.
34
     * This creates a proxy string suitable for use with the AWS SDK.
42
     *
35
     *
-
 
36
     * @return string the string to use for proxy settings.
43
     * @return string the string to use for proxy settings.
37
     * @deprecated Since Moodle 4.5
-
 
38
     */
-
 
39
    #[\core\attribute\deprecated(
-
 
40
        'aws_helper::get_proxy_string()',
-
 
41
        since: '4.5',
-
 
42
        mdl: 'MDL-80962',
44
     */
43
    )]
-
 
44
    public static function get_proxy_string(): string {
45
    public static function get_proxy_string(): string {
45
        \core\deprecation::emit_deprecation(__FUNCTION__);
46
        global $CFG;
46
        global $CFG;
47
        $proxy = '';
47
        $proxy = '';
48
        if (empty($CFG->proxytype)) {
48
        if (empty($CFG->proxytype)) {
49
            return $proxy;
49
            return $proxy;
Línea 69... Línea 69...
69
    /**
69
    /**
70
     * Configure the provided AWS client to route traffic via the moodle proxy for any hosts not excluded.
70
     * Configure the provided AWS client to route traffic via the moodle proxy for any hosts not excluded.
71
     *
71
     *
72
     * @param AwsClient $client
72
     * @param AwsClient $client
73
     * @return AwsClient
73
     * @return AwsClient
-
 
74
     * @deprecated Since Moodle 4.5
74
     */
75
     */
-
 
76
    #[\core\attribute\deprecated(
-
 
77
        'aws_helper::configure_client_proxy()',
-
 
78
        since: '4.5',
-
 
79
        mdl: 'MDL-80962',
-
 
80
    )]
75
    public static function configure_client_proxy(AwsClient $client): AwsClient {
81
    public static function configure_client_proxy(AwsClient $client): AwsClient {
-
 
82
        \core\deprecation::emit_deprecation(__FUNCTION__);
76
        $client->getHandlerList()->appendBuild(self::add_proxy_when_required(), 'proxy_bypass');
83
        $client->getHandlerList()->appendBuild(self::add_proxy_when_required(), 'proxy_bypass');
77
        return $client;
84
        return $client;
78
    }
85
    }
Línea 79... Línea 86...
79
 
86
 
80
    /**
87
    /**
81
     * Generate a middleware higher order function to wrap the handler and append proxy configuration based on target.
88
     * Generate a middleware higher order function to wrap the handler and append proxy configuration based on target.
82
     *
89
     *
-
 
90
     * @return callable Middleware high order callable.
83
     * @return callable Middleware high order callable.
91
     * @deprecated Since Moodle 4.5
-
 
92
     */
-
 
93
    #[\core\attribute\deprecated(
-
 
94
        'aws_helper::add_proxy_when_required()',
-
 
95
        since: '4.5',
-
 
96
        mdl: 'MDL-80962',
84
     */
97
    )]
-
 
98
    protected static function add_proxy_when_required(): callable {
85
    protected static function add_proxy_when_required(): callable {
99
        \core\deprecation::emit_deprecation(__FUNCTION__);
86
        return function (callable $fn) {
100
        return function (callable $fn) {
87
            return function (CommandInterface $command, ?RequestInterface $request = null) use ($fn) {
101
            return function (CommandInterface $command, ?RequestInterface $request = null) use ($fn) {
88
                if (isset($request)) {
102
                if (isset($request)) {
89
                    $target = (string) $request->getUri();
103
                    $target = (string) $request->getUri();