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\router\parameters;
18
 
19
use core\param;
20
use core\router\schema\parameters\mapped_property_parameter;
21
use core\router\schema\referenced_object;
22
use Psr\Http\Message\ServerRequestInterface;
23
 
24
/**
25
 * A return URL parameter referenced in the query parameters.
26
 *
27
 * @package    core
28
 * @copyright  Andrew Lyons <andrew@nicols.co.uk>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
class query_returnurl extends \core\router\schema\parameters\query_parameter implements
32
    mapped_property_parameter,
33
    referenced_object
34
{
35
    /**
36
     * Create a new query_returnurl parameter.
37
     *
38
     * @param string $name The name of the parameter to use for the return URL
39
     * @param mixed ...$extra Additional arguments
40
     */
41
    public function __construct(
42
        string $name = 'returnurl',
43
        ...$extra,
44
    ) {
45
        $extra['name'] = $name;
46
        $extra['type'] = param::LOCALURL;
47
 
48
        parent::__construct(...$extra);
49
    }
50
 
51
    #[\Override]
52
    public function add_attributes_for_parameter_value(
53
        ServerRequestInterface $request,
54
        string $value,
55
    ): ServerRequestInterface {
56
        return $request->withAttribute($this->name, new \core\url($value));
57
    }
58
}