Merge branch 'MDL-78758' of https://github.com/paulholden/moodle
This commit is contained in:
@@ -90,16 +90,24 @@ abstract class datasource extends base {
|
||||
/**
|
||||
* Add default datasource columns to the report
|
||||
*
|
||||
* This method is optional and can be called when the report is created to add the default columns defined in the
|
||||
* selected datasource.
|
||||
* Uses column data returned by the source {@see get_default_columns} and {@see get_default_column_sorting} methods
|
||||
*
|
||||
* @throws coding_exception If default column sorting refers to an invalid column
|
||||
*/
|
||||
public function add_default_columns(): void {
|
||||
$reportid = $this->get_report_persistent()->get('id');
|
||||
|
||||
// Retrieve default column sorting, and track index of both sorted/non-sorted columns.
|
||||
$columnidentifiers = $this->get_default_columns();
|
||||
$defaultcolumnsorting = array_intersect_key($this->get_default_column_sorting(),
|
||||
|
||||
$defaultcolumnsorting = $this->get_default_column_sorting();
|
||||
$defaultcolumnsortinginvalid = array_diff_key($defaultcolumnsorting,
|
||||
array_fill_keys($columnidentifiers, 1));
|
||||
|
||||
if (count($defaultcolumnsortinginvalid) > 0) {
|
||||
throw new coding_exception('Invalid column name', array_key_first($defaultcolumnsortinginvalid));
|
||||
}
|
||||
|
||||
$columnnonsortingindex = count($defaultcolumnsorting) + 1;
|
||||
|
||||
foreach ($columnidentifiers as $uniqueidentifier) {
|
||||
@@ -120,14 +128,17 @@ abstract class datasource extends base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the columns that will be added to the report once is created
|
||||
* Return the default columns that will be added to the report upon creation, by {@see add_default_columns}
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
abstract public function get_default_columns(): array;
|
||||
|
||||
/**
|
||||
* Return the default sorting that will be added to the report once it is created
|
||||
* Return the default column sorting that will be set for the report upon creation, by {@see add_default_columns}
|
||||
*
|
||||
* When overriding this method in child classes, column identifiers specified must refer to default columns returned from
|
||||
* the {@see get_default_columns} method
|
||||
*
|
||||
* @return int[] array [column identifier => SORT_ASC/SORT_DESC]
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@ Information provided here is intended especially for developers.
|
||||
* The following report entity filters/conditions have been deprecated, with replacements as follows:
|
||||
- `enrolment:method` => `enrol:plugin`
|
||||
* The `add_base_condition_sql` method of the base report class will now ignore empty where clauses
|
||||
* If a non-default column is specified in a datasource `get_default_column_sorting` method, a coding exception will be thrown
|
||||
* Trying to add/annotate duplicate entity names to a report will now throw a coding exception
|
||||
* The `get_default_entity_name` method of the base entity class is now private, and shouldn't be overridden in extending classes
|
||||
* Two new methods:
|
||||
|
||||
Reference in New Issue
Block a user