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 |
declare(strict_types=1);
|
|
|
18 |
|
|
|
19 |
namespace core_enrol\output;
|
|
|
20 |
|
|
|
21 |
use core\output\named_templatable;
|
|
|
22 |
use core\output\renderable;
|
|
|
23 |
use core\output\single_button;
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Allows to render a widget provided by enrol_plugin::enrol_page_hook()
|
|
|
27 |
*
|
|
|
28 |
* @package core_enrol
|
|
|
29 |
* @copyright Marina Glancy
|
|
|
30 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
31 |
*/
|
|
|
32 |
class enrol_page implements named_templatable, renderable {
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Constructor
|
|
|
36 |
*
|
|
|
37 |
* @param \stdClass $instance
|
|
|
38 |
* @param string|null $header
|
|
|
39 |
* @param string|null $body
|
|
|
40 |
* @param array $buttons
|
|
|
41 |
*/
|
|
|
42 |
public function __construct(
|
|
|
43 |
/** @var \stdClass */
|
|
|
44 |
protected \stdClass $instance,
|
|
|
45 |
/** @var string|null */
|
|
|
46 |
protected ?string $header = null,
|
|
|
47 |
/** @var string|null */
|
|
|
48 |
protected ?string $body = null,
|
|
|
49 |
/** @var single_button[] */
|
|
|
50 |
protected array $buttons = []
|
|
|
51 |
) {
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
#[\Override]
|
|
|
55 |
public function export_for_template(\core\output\renderer_base $output) {
|
|
|
56 |
return [
|
|
|
57 |
'enrol' => $this->instance->enrol,
|
|
|
58 |
'instanceid' => $this->instance->id,
|
|
|
59 |
'header' => $this->header,
|
|
|
60 |
'body' => $this->body,
|
|
|
61 |
'buttons' => array_map(fn($b) => $b->export_for_template($output), $this->buttons),
|
|
|
62 |
'hasbuttons' => !empty($this->buttons),
|
|
|
63 |
];
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
#[\Override]
|
|
|
67 |
public function get_template_name(\core\output\renderer_base $renderer): string {
|
|
|
68 |
return 'core_enrol/enrol_page';
|
|
|
69 |
}
|
|
|
70 |
}
|