Skip to content

Commit

Permalink
New method; ListingTable\Table->applyFilters()
Browse files Browse the repository at this point in the history
This provides better support for fine-tuning the embedded dataset.
  • Loading branch information
cdp1337 committed Jun 21, 2017
1 parent e531693 commit 7b14e36
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/core/libs/core/listingtable/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,31 @@ public function loadFiltersFromRequest($request = null){
$this->getFilters()->load($request);
}

public function render($section = null){
if(!$this->_applied){
$this->getFilters()->applyToFactory($this->getModelFactory());

/**
* Apply the automatic filters to the embedded Factory.
*
* This is usually called automatically and doesn't need to be called externally
* unless the fully resolved Factory is required by an external source,
* (such as graph data or something similar).
*/
public function applyFilters(){
if(!$this->_applied){
$this->getFilters()->applyToFactory($this->getModelFactory());
$this->_applied = true;
}
}

public function render($section){
// Ensure that the filters are applied first!
// This method is safe to call multiple times.
$this->applyFilters();

// Load the results into the internal array.
if($this->_results === null){
$this->_results = $this->getModelFactory()->get();
$this->_applied = true;
}

switch($section){
case null:
return $this->_renderHead() . $this->_renderBody() . $this->_renderFoot();
Expand Down

0 comments on commit 7b14e36

Please sign in to comment.