Skip to content

Commit

Permalink
MDL-68454 table: Move filterset functionality to flexible_table
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed May 4, 2020
1 parent c00552b commit 56143dd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
16 changes: 0 additions & 16 deletions lib/table/classes/dynamic.php
Expand Up @@ -30,7 +30,6 @@
defined('MOODLE_INTERNAL') || die();

use moodle_url;
use core_table\local\filter\filterset;

/**
* Interface dynamic.
Expand All @@ -45,19 +44,4 @@ interface dynamic {
* @return moodle_url
*/
public function get_base_url(): moodle_url;

/**
* Set the filterset filters build table object.
*
* @param filterset $filterset The filterset object to get the filters from.
* @return void
*/
public function set_filterset(filterset $filterset): void;

/**
* Get the currently defined filterset.
*
* @return filterset
*/
public function get_filterset(): ?filterset;
}
27 changes: 27 additions & 0 deletions lib/tablelib.php
Expand Up @@ -46,6 +46,7 @@
define('TABLE_P_BOTTOM', 2);
/**#@-*/

use core_table\local\filter\filterset;

/**
* @package moodlecore
Expand Down Expand Up @@ -157,6 +158,12 @@ class flexible_table {
/** @var array $hiddencolumns List of hidden columns. */
protected $hiddencolumns;

/**
* @var filterset The currently applied filerset
* This is required for dynamic tables, but can be used by other tables too if desired.
*/
protected $filterset = null;

/**
* Constructor
* @param string $uniqueid all tables have to have a unique id, this is used
Expand Down Expand Up @@ -1711,6 +1718,26 @@ public function get_context(): context {

return $PAGE->context;
}

/**
* Set the filterset in the table class.
*
* The use of filtersets is a requirement for dynamic tables, but can be used by other tables too if desired.
*
* @param filterset $filterset The filterset object to get filters and table parameters from
*/
public function set_filterset(filterset $filterset): void {
$this->filterset = $filterset;
}

/**
* Get the currently defined filterset.
*
* @return filterset
*/
public function get_filterset(): ?filterset {
return $this->filterset;
}
}


Expand Down
12 changes: 1 addition & 11 deletions user/classes/table/participants.php
Expand Up @@ -495,8 +495,7 @@ public function set_selectall(bool $selectall): void {
* @param filterset $filterset The filterset object to get the filters from.
*/
public function set_filterset(filterset $filterset): void {
// Store the filterset for later.
$this->filterset = $filterset;
parent::set_filterset($filterset);

// Get the context.
$this->courseid = $filterset->get_filter('courseid')->current();
Expand Down Expand Up @@ -560,13 +559,4 @@ public function get_base_url(): moodle_url {
public function get_context(): context {
return $this->context;
}

/**
* Get the currently defined filterset.
*
* @return filterset
*/
public function get_filterset(): ?filterset {
return $this->filterset;
}
}

0 comments on commit 56143dd

Please sign in to comment.