mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-76867 core_table: Allow dynamic table filterset to be specified
The previous behaviour guessed the table filterset based on the table's class name, but this is not very flexible if you wish to create an abstract table class and use a generic filter for all implementations. This change adds the ability to specify the filterset class, with the default behaviour using the table class name as a prefix.
This commit is contained in:
parent
fdb1df2bfd
commit
f4a48a517b
2
lib/table/classes/external/dynamic/get.php
vendored
2
lib/table/classes/external/dynamic/get.php
vendored
@ -201,7 +201,7 @@ class get extends external_api {
|
||||
throw new \UnexpectedValueException("Table handler class {$tableclass} does not support dynamic updating.");
|
||||
}
|
||||
|
||||
$filtersetclass = "{$tableclass}_filterset";
|
||||
$filtersetclass = $tableclass::get_filterset_class();
|
||||
if (!class_exists($filtersetclass)) {
|
||||
throw new \UnexpectedValueException("The filter specified ({$filtersetclass}) is invalid.");
|
||||
}
|
||||
|
@ -1953,6 +1953,15 @@ class flexible_table {
|
||||
return $this->filterset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class used as a filterset.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_filterset_class(): string {
|
||||
return static::class . '_filterset';
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to guess the base URL.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user