Proyectos de Subversion Moodle

Rev

| 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
namespace mod_data\output;
18
 
19
use templatable;
20
use renderable;
21
 
22
/**
23
 * Renderable class for the action bar elements in the presets page in the database activity.
24
 *
25
 * @package    mod_data
26
 * @copyright  2021 Mihail Geshoski <mihail@moodle.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
29
class presets_action_bar implements templatable, renderable {
30
 
31
    /** @var int $id The database module id. */
32
    private $cmid;
33
 
34
    /** @var \action_menu $actionsselect The presets actions selector object. */
35
    private $actionsselect;
36
 
37
    /**
38
     * The class constructor.
39
     *
40
     * @param int $cmid The database module id
41
     * @param \action_menu|null $actionsselect The presets actions selector object.
42
     */
43
    public function __construct(int $cmid, ?\action_menu $actionsselect) {
44
        $this->cmid = $cmid;
45
        $this->actionsselect = $actionsselect;
46
    }
47
 
48
    /**
49
     * Export the data for the mustache template.
50
     *
51
     * @param \renderer_base $output The renderer to be used to render the action bar elements.
52
     * @return array
53
     */
54
    public function export_for_template(\renderer_base $output): array {
55
        $data = [
56
            'id' => $this->cmid,
57
        ];
58
 
59
        if ($this->actionsselect) {
60
            $data['actionsselect'] = $this->actionsselect->export_for_template($output);
61
        }
62
 
63
        return $data;
64
    }
65
}