Make available to extends Lists records

This commit is contained in:
leocavalcante 2016-03-18 21:05:23 -03:00
parent 076f5199af
commit f5f7ed08e4
2 changed files with 24 additions and 1 deletions

View File

@ -157,6 +157,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);
});
@ -423,7 +427,16 @@ class ListController extends ControllerBehavior
}
/**
* Controller override: Extend the query used for populating the filter
* 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.
* @param October\Rain\Database\Builder $query
* @param array $scope

View File

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