Merge pull request #1853 from leocavalcante/feature-list-extend-records

Make available to extends Lists records
This commit is contained in:
Luke Towers 2017-02-14 02:17:16 -06:00 committed by GitHub
commit fd3fbf5e52
2 changed files with 24 additions and 1 deletions

View File

@ -163,6 +163,10 @@ class ListController extends ControllerBehavior
$this->controller->listExtendQuery($query, $definition);
});
$widget->bindEvent('list.extendRecords', function ($records) use ($definition) {
$this->controller->listExtendRecords($records, $definition);
});
$widget->bindEvent('list.injectRowClass', function ($record) use ($definition) {
return $this->controller->listInjectRowClass($record, $definition);
});
@ -463,6 +467,15 @@ class ListController extends ControllerBehavior
{
}
/**
* Controller override: Extend the records used for populating the list
* after the query is processed.
* @param Illuminate\Contracts\Pagination\LengthAwarePaginator|Illuminate\Database\Eloquent\Collection $records
*/
public function listExtendRecords($records, $definition = null)
{
}
/**
* Controller override: Extend the query used for populating the filter
* options before the default query is processed.

View File

@ -524,6 +524,16 @@ class Lists extends WidgetBase
$records = $model->get();
}
/*
* Extensibility
*/
if (
($event = $this->fireEvent('list.extendRecords', [$records], true)) ||
($event = Event::fire('backend.list.extendRecords', [$this, $records], true))
) {
$records = $event;
}
return $this->records = $records;
}