Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
namespace core_files\tests\redactor\services;
18
 
19
use core_files\redactor\services\file_redactor_service_interface;
20
use core_files\redactor\services\service;
21
 
22
/**
23
 * Dummy service for testing only.
24
 *
25
 * @package   core
26
 * @copyright Meirza <meirza.arson@moodle.com>
27
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
29
class dummy_file_service extends service implements file_redactor_service_interface {
30
    #[\Override]
31
    public function redact_file_by_content(string $mimetype, string $filecontent): string {
32
        return "redacted:{$filecontent}";
33
    }
34
 
35
    #[\Override]
36
    public function redact_file_by_path(string $mimetype, string $filepath): string {
37
        return "/redacted{$filepath}";
38
    }
39
 
40
    /**
41
     * Returns true if the service is enabled, and "false" if it is not.
42
     *
43
     * @return bool
44
     */
45
    public function is_enabled(): bool {
46
        return true;
47
    }
48
 
49
    /**
50
     * Determines whether a certain mime-type is supported by the service.
51
     * It will return true if the mime-type is supported, and false if it is not.
52
     *
53
     * @param string $mimetype
54
     * @return bool
55
     */
56
    public function is_mimetype_supported(string $mimetype): bool {
57
        if (str_starts_with($mimetype, 'image/')) {
58
            return true;
59
        }
60
 
61
        return false;
62
    }
63
 
64
    /**
65
     * Adds settings to the provided admin settings page.
66
     *
67
     * @param \admin_settingpage $settings The admin settings page to which settings are added.
68
     */
69
    public static function add_settings(\admin_settingpage $settings): void {
70
        // The function body.
71
    }
72
}