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
/**
18
 * A data source defines which query, fields, and filters are used to retrieve data from a data grid.
19
 *
20
 * @package    block_dash
21
 * @copyright  2019 bdecent gmbh <https://bdecent.de>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace block_dash\local\data_source;
26
 
27
use block_dash\local\dash_framework\query_builder\builder;
28
use block_dash\local\dash_framework\structure\field_interface;
29
use block_dash\local\dash_framework\structure\table;
30
use block_dash\local\data_grid\data\data_collection_interface;
31
use block_dash\local\data_grid\filter\filter_collection_interface;
32
use block_dash\local\layout\layout_interface;
33
/**
34
 * A data source defines which query, fields, and filters are used to retrieve data from a data grid.
35
 *
36
 * @package block_dash
37
 */
38
interface data_source_interface {
39
 
40
    /**
41
     * Get human readable name of data source.
42
     *
43
     * @return string
44
     */
45
    public function get_name();
46
 
47
    /**
48
     * Get filter collection for data grid. Build if necessary.
49
     *
50
     * @return filter_collection_interface
51
     */
52
    public function get_filter_collection();
53
 
54
    /**
55
     * Modify objects before data is retrieved.
56
     */
57
    public function before_data();
58
 
59
    /**
60
     * Get data collection.
61
     *
62
     * @return data_collection_interface
63
     */
64
    public function get_data();
65
 
66
    /**
67
     * Modify objects after data is retrieved.
68
     *
69
     * @param data_collection_interface $datacollection
70
     */
71
    public function after_data(data_collection_interface $datacollection);
72
 
73
 
74
    /**
75
     * Explicitly set layout.
76
     *
77
     * @param layout_interface $layout
78
     */
79
    public function set_layout(layout_interface $layout);
80
 
81
    /**
82
     * Get layout.
83
     *
84
     * @return layout_interface
85
     */
86
    public function get_layout();
87
 
88
    /**
89
     * Get context.
90
     *
91
     * @return \context
92
     */
93
    public function get_context();
94
 
95
    /**
96
     * Get template variables.
97
     *
98
     * @param \renderer_base $output
99
     * @return array|\renderer_base|\stdClass|string
100
     */
101
    public function export_for_template(\renderer_base $output);
102
 
103
    /**
104
     * Add form fields to the block edit form. IMPORTANT: Prefix field names with config_ otherwise the values will
105
     * not be saved.
106
     *
107
     * @param \moodleform $form
108
     * @param \MoodleQuickForm $mform
109
     */
110
    public function build_preferences_form(\moodleform $form, \MoodleQuickForm $mform);
111
 
112
    /**
113
     * Get a specific preference.
114
     *
115
     * @param string $name
116
     * @return mixed|array
117
     */
118
    public function get_preferences($name);
119
 
120
    /**
121
     * Get all preferences associated with the data source.
122
     *
123
     * @return array
124
     */
125
    public function get_all_preferences();
126
 
127
    /**
128
     * Set preferences on this data source.
129
     *
130
     * @param array $preferences
131
     */
132
    public function set_preferences(array $preferences);
133
 
134
    /**
135
     * Get query builder with basis of query.
136
     *
137
     * @return builder
138
     */
139
    public function get_query_template(): builder;
140
 
141
    /**
142
     * Get fully built query for execution.
143
     *
144
     * @return builder
145
     */
146
    public function get_query(): builder;
147
 
148
    /**
149
     * Get count query template.
150
     *
151
     * @return string
152
     */
153
    public function get_count_query_template();
154
 
155
    /**
156
     * Get group by fields.
157
     *
158
     * @return string
159
     */
160
    public function get_groupby();
161
 
162
    /**
163
     * Add table to this data source. If the table is used in a join in the main query.
164
     *
165
     * @param table $table
166
     */
167
    public function add_table(table $table): void;
168
 
169
    /**
170
     * Get tables that are in this data source's main query.
171
     *
172
     * @return array
173
     */
174
    public function get_tables(): array;
175
 
176
    /**
177
     * Get available fields for this data source.
178
     *
179
     * @return field_interface[]
180
     */
181
    public function get_available_fields();
182
 
183
    /**
184
     * Get field by name. Returns null if not found.
185
     *
186
     * @param string $name
187
     * @return ?field_interface
188
     */
189
    public function get_field(string $name): ?field_interface;
190
 
191
    /**
192
     * Check if field exists in data source.
193
     *
194
     * @param string $name
195
     * @return bool
196
     */
197
    public function has_field(string $name): bool;
198
 
199
    /**
200
     * Get sorted fields based on preferences.
201
     *
202
     * @return field_interface[]
203
     */
204
    public function get_sorted_fields();
205
 
206
    /**
207
     * Build filter collection.
208
     *
209
     * @return filter_collection_interface
210
     */
211
    public function build_filter_collection();
212
 
213
    /**
214
     * Set block instance.
215
     *
216
     * @param \block_base $blockinstance
217
     */
218
    public function set_block_instance(\block_base $blockinstance);
219
 
220
    /**
221
     * Get block instance.
222
     *
223
     * @return null|\block_base
224
     */
225
    public function get_block_instance();
226
}