Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
/**
18
 * The chooser_section renderable.
19
 *
20
 * @package    core
21
 * @copyright  2016 Frédéric Massart - FMCorz.net
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace core\output;
26
 
27
use lang_string;
28
use stdClass;
29
 
30
/**
31
 * The chooser_section renderable class.
32
 *
33
 * @package    core
34
 * @copyright  2016 Frédéric Massart - FMCorz.net
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
class chooser_section implements renderable, templatable {
38
    /** @var string $id An identifier for the section. */
39
    public $id;
40
    /** @var lang_string $label The label of the section. */
41
    public $label;
42
    /** @var chooser_item[] $items The items in this section. */
43
    public $items;
44
 
45
    /**
46
     * Constructor.
47
     *
48
     * @param string $id An identifier for the section.
49
     * @param lang_string $label The label of the section.
50
     * @param chooser_item[] $items The items in this section.
51
     */
52
    public function __construct($id, lang_string $label, array $items) {
53
        $this->id = $id;
54
        $this->label = $label;
55
        $this->items = $items;
56
    }
57
 
58
    /**
59
     * Export for template.
60
     *
61
     * @param renderer_base The renderer.
62
     * @return stdClass
63
     */
64
    public function export_for_template(renderer_base $output) {
65
        $data = new stdClass();
66
        $data->id = $this->id;
67
        $data->label = (string) $this->label;
1441 ariadna 68
        $data->items = array_map(function ($item) use ($output) {
1 efrain 69
            return $item->export_for_template($output);
70
        }, array_values($this->items));
71
        return $data;
72
    }
73
}