2014-05-14 23:24:20 +10:00
|
|
|
<?php namespace Backend\Behaviors;
|
|
|
|
|
|
|
|
use Str;
|
|
|
|
use Lang;
|
|
|
|
use Event;
|
2015-01-28 18:03:35 +11:00
|
|
|
use SystemException;
|
2014-05-14 23:24:20 +10:00
|
|
|
use Backend\Classes\ControllerBehavior;
|
2015-01-27 20:02:20 +11:00
|
|
|
use League\Csv\Writer;
|
|
|
|
use SplTempFileObject;
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List Controller Behavior
|
|
|
|
* Adds features for working with backend lists.
|
|
|
|
*
|
|
|
|
* @package october\backend
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*/
|
|
|
|
class ListController extends ControllerBehavior
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array List definitions, keys for alias and value for configuration.
|
|
|
|
*/
|
2014-08-01 18:20:55 +10:00
|
|
|
protected $listDefinitions;
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The primary list alias to use. Default: list
|
|
|
|
*/
|
2014-08-01 18:20:55 +10:00
|
|
|
protected $primaryDefinition;
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Backend\Classes\WidgetBase Reference to the list widget object.
|
|
|
|
*/
|
2014-08-01 18:20:55 +10:00
|
|
|
protected $listWidgets = [];
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var WidgetBase Reference to the toolbar widget objects.
|
|
|
|
*/
|
2014-08-01 18:20:55 +10:00
|
|
|
protected $toolbarWidgets = [];
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2014-08-11 21:46:29 +10:00
|
|
|
/**
|
|
|
|
* @var WidgetBase Reference to the filter widget objects.
|
|
|
|
*/
|
|
|
|
protected $filterWidgets = [];
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
protected $requiredProperties = ['listConfig'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array Configuration values that must exist when applying the primary config file.
|
|
|
|
* - modelClass: Class name for the model
|
|
|
|
* - list: List column definitions
|
|
|
|
*/
|
|
|
|
protected $requiredConfig = ['modelClass', 'list'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Behavior constructor
|
|
|
|
* @param Backend\Classes\Controller $controller
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct($controller)
|
|
|
|
{
|
|
|
|
parent::__construct($controller);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extract list definitions
|
|
|
|
*/
|
|
|
|
if (is_array($controller->listConfig)) {
|
2014-05-17 18:08:01 +02:00
|
|
|
$this->listDefinitions = $controller->listConfig;
|
|
|
|
$this->primaryDefinition = key($this->listDefinitions);
|
2014-11-04 17:41:48 +11:00
|
|
|
}
|
|
|
|
else {
|
2014-05-17 18:08:01 +02:00
|
|
|
$this->listDefinitions = ['list' => $controller->listConfig];
|
2014-05-14 23:24:20 +10:00
|
|
|
$this->primaryDefinition = 'list';
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build configuration
|
|
|
|
*/
|
2014-05-17 18:08:01 +02:00
|
|
|
$this->setConfig($this->listDefinitions[$this->primaryDefinition], $this->requiredConfig);
|
2014-05-14 23:24:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates all the list widgets based on the definitions.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function makeLists()
|
|
|
|
{
|
2014-05-17 18:08:01 +02:00
|
|
|
foreach ($this->listDefinitions as $definition => $config) {
|
2014-05-14 23:24:20 +10:00
|
|
|
$this->listWidgets[$definition] = $this->makeList($definition);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->listWidgets;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare the widgets used by this action
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function makeList($definition = null)
|
|
|
|
{
|
2014-10-10 22:34:57 +02:00
|
|
|
if (!$definition || !isset($this->listDefinitions[$definition])) {
|
2014-05-14 23:24:20 +10:00
|
|
|
$definition = $this->primaryDefinition;
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2014-05-17 18:08:01 +02:00
|
|
|
$listConfig = $this->makeConfig($this->listDefinitions[$definition], $this->requiredConfig);
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the model
|
|
|
|
*/
|
|
|
|
$class = $listConfig->modelClass;
|
|
|
|
$model = new $class();
|
|
|
|
$model = $this->controller->listExtendModel($model, $definition);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prepare the list widget
|
|
|
|
*/
|
|
|
|
$columnConfig = $this->makeConfig($listConfig->list);
|
|
|
|
$columnConfig->model = $model;
|
|
|
|
$columnConfig->alias = $definition;
|
2014-10-24 17:45:11 +11:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prepare the columns configuration
|
|
|
|
*/
|
|
|
|
$configFieldsToTransfer = [
|
|
|
|
'recordUrl',
|
|
|
|
'recordOnClick',
|
|
|
|
'recordsPerPage',
|
|
|
|
'noRecordsMessage',
|
|
|
|
'defaultSort',
|
|
|
|
'showSorting',
|
|
|
|
'showSetup',
|
|
|
|
'showCheckboxes',
|
|
|
|
'showTree',
|
|
|
|
'treeExpanded',
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($configFieldsToTransfer as $field) {
|
|
|
|
if (isset($listConfig->{$field})) {
|
|
|
|
$columnConfig->{$field} = $listConfig->{$field};
|
|
|
|
}
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/*
|
2014-10-24 17:45:11 +11:00
|
|
|
* List Widget with extensibility
|
2014-05-14 23:24:20 +10:00
|
|
|
*/
|
2014-10-24 17:45:11 +11:00
|
|
|
$widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig);
|
|
|
|
|
|
|
|
$widget->bindEvent('list.extendColumns', function () use ($widget) {
|
|
|
|
$this->controller->listExtendColumns($widget);
|
|
|
|
});
|
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
$widget->bindEvent('list.extendQueryBefore', function ($query) use ($definition) {
|
2014-05-14 23:24:20 +10:00
|
|
|
$this->controller->listExtendQueryBefore($query, $definition);
|
|
|
|
});
|
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
$widget->bindEvent('list.extendQuery', function ($query) use ($definition) {
|
2014-05-14 23:24:20 +10:00
|
|
|
$this->controller->listExtendQuery($query, $definition);
|
|
|
|
});
|
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
$widget->bindEvent('list.injectRowClass', function ($record) use ($definition) {
|
2014-05-14 23:24:20 +10:00
|
|
|
return $this->controller->listInjectRowClass($record, $definition);
|
|
|
|
});
|
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
$widget->bindEvent('list.overrideColumnValue', function ($record, $column, $value) use ($definition) {
|
2014-05-14 23:24:20 +10:00
|
|
|
return $this->controller->listOverrideColumnValue($record, $column->columnName, $definition);
|
|
|
|
});
|
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
$widget->bindEvent('list.overrideHeaderValue', function ($column, $value) use ($definition) {
|
2014-05-14 23:24:20 +10:00
|
|
|
return $this->controller->listOverrideHeaderValue($column->columnName, $definition);
|
|
|
|
});
|
|
|
|
|
2014-10-24 17:45:11 +11:00
|
|
|
$widget->bindToController();
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
/*
|
|
|
|
* Prepare the toolbar widget (optional)
|
|
|
|
*/
|
|
|
|
if (isset($listConfig->toolbar)) {
|
|
|
|
$toolbarConfig = $this->makeConfig($listConfig->toolbar);
|
|
|
|
$toolbarConfig->alias = $widget->alias . 'Toolbar';
|
|
|
|
$toolbarWidget = $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig);
|
|
|
|
$toolbarWidget->bindToController();
|
|
|
|
$toolbarWidget->cssClasses[] = 'list-header';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Link the Search Widget to the List Widget
|
|
|
|
*/
|
|
|
|
if ($searchWidget = $toolbarWidget->getSearchWidget()) {
|
2014-10-10 22:34:57 +02:00
|
|
|
$searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) {
|
2014-05-14 23:24:20 +10:00
|
|
|
$widget->setSearchTerm($searchWidget->getActiveTerm());
|
2014-07-03 18:35:35 +10:00
|
|
|
return $widget->onRefresh();
|
2014-05-14 23:24:20 +10:00
|
|
|
});
|
|
|
|
|
|
|
|
// Find predefined search term
|
|
|
|
$widget->setSearchTerm($searchWidget->getActiveTerm());
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->toolbarWidgets[$definition] = $toolbarWidget;
|
|
|
|
}
|
|
|
|
|
2014-08-11 21:46:29 +10:00
|
|
|
/*
|
|
|
|
* Prepare the filter widget (optional)
|
|
|
|
*/
|
|
|
|
if (isset($listConfig->filter)) {
|
2014-08-13 21:23:19 +10:00
|
|
|
$widget->cssClasses[] = 'list-flush';
|
|
|
|
|
2014-08-11 21:46:29 +10:00
|
|
|
$filterConfig = $this->makeConfig($listConfig->filter);
|
|
|
|
$filterConfig->alias = $widget->alias . 'Filter';
|
|
|
|
$filterWidget = $this->makeWidget('Backend\Widgets\Filter', $filterConfig);
|
|
|
|
$filterWidget->bindToController();
|
|
|
|
|
2014-08-13 21:23:19 +10:00
|
|
|
/*
|
|
|
|
* Filter the list when the scopes are changed
|
|
|
|
*/
|
2014-10-10 22:34:57 +02:00
|
|
|
$filterWidget->bindEvent('filter.update', function () use ($widget, $filterWidget) {
|
2014-08-13 21:23:19 +10:00
|
|
|
$widget->addFilter([$filterWidget, 'applyAllScopesToQuery']);
|
|
|
|
return $widget->onRefresh();
|
|
|
|
});
|
|
|
|
|
2014-12-23 14:57:28 +01:00
|
|
|
/*
|
|
|
|
* Extend the query of the list of options
|
|
|
|
*/
|
|
|
|
$filterWidget->bindEvent('filter.extendQuery', function($query, $scope) {
|
|
|
|
$this->controller->listFilterExtendQuery($query, $scope);
|
|
|
|
});
|
|
|
|
|
2014-08-13 21:23:19 +10:00
|
|
|
// Apply predefined filter values
|
|
|
|
$widget->addFilter([$filterWidget, 'applyAllScopesToQuery']);
|
2014-08-11 21:46:29 +10:00
|
|
|
|
|
|
|
$this->filterWidgets[$definition] = $filterWidget;
|
|
|
|
}
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
return $widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index Controller action.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2014-10-10 22:34:57 +02:00
|
|
|
$this->controller->pageTitle = $this->controller->pageTitle ?: trans($this->getConfig(
|
|
|
|
'title',
|
|
|
|
'backend::lang.list.default_title'
|
|
|
|
));
|
2014-05-14 23:24:20 +10:00
|
|
|
$this->controller->bodyClass = 'slim-container';
|
|
|
|
$this->makeLists();
|
|
|
|
}
|
|
|
|
|
2015-01-27 20:02:20 +11:00
|
|
|
/**
|
|
|
|
* Export Controller action.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function export()
|
|
|
|
{
|
|
|
|
return $this->listExportCsv();
|
|
|
|
}
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
/**
|
|
|
|
* Renders the widget collection.
|
2014-05-28 21:34:54 +10:00
|
|
|
* @param string $definition Optional list definition.
|
2014-05-14 23:24:20 +10:00
|
|
|
* @return string Rendered HTML for the list.
|
|
|
|
*/
|
|
|
|
public function listRender($definition = null)
|
|
|
|
{
|
2014-10-10 22:34:57 +02:00
|
|
|
if (!count($this->listWidgets)) {
|
2014-05-14 23:24:20 +10:00
|
|
|
throw new SystemException(Lang::get('backend::lang.list.behavior_not_ready'));
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
if (!$definition || !isset($this->listDefinitions[$definition])) {
|
2014-05-14 23:24:20 +10:00
|
|
|
$definition = $this->primaryDefinition;
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
$collection = [];
|
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
if (isset($this->toolbarWidgets[$definition])) {
|
2014-05-14 23:24:20 +10:00
|
|
|
$collection[] = $this->toolbarWidgets[$definition]->render();
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
if (isset($this->filterWidgets[$definition])) {
|
2014-08-11 21:46:29 +10:00
|
|
|
$collection[] = $this->filterWidgets[$definition]->render();
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-08-11 21:46:29 +10:00
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
$collection[] = $this->listWidgets[$definition]->render();
|
|
|
|
|
|
|
|
return implode(PHP_EOL, $collection);
|
|
|
|
}
|
|
|
|
|
2014-05-28 21:34:54 +10:00
|
|
|
/**
|
|
|
|
* Refreshes the list container only, useful for returning in custom AJAX requests.
|
|
|
|
* @param string $definition Optional list definition.
|
|
|
|
* @return array The list element selector as the key, and the list contents are the value.
|
|
|
|
*/
|
|
|
|
public function listRefresh($definition = null)
|
|
|
|
{
|
2014-10-10 22:34:57 +02:00
|
|
|
if (!count($this->listWidgets)) {
|
2014-05-28 21:34:54 +10:00
|
|
|
$this->makeLists();
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-05-28 21:34:54 +10:00
|
|
|
|
2014-10-10 22:34:57 +02:00
|
|
|
if (!$definition || !isset($this->listDefinitions[$definition])) {
|
2014-05-28 21:34:54 +10:00
|
|
|
$definition = $this->primaryDefinition;
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|
2014-05-28 21:34:54 +10:00
|
|
|
|
2014-07-03 18:35:35 +10:00
|
|
|
return $this->listWidgets[$definition]->onRefresh();
|
2014-05-28 21:34:54 +10:00
|
|
|
}
|
|
|
|
|
2014-10-11 18:06:14 +11:00
|
|
|
/**
|
|
|
|
* Returns the widget used by this behavior.
|
|
|
|
* @return Backend\Classes\WidgetBase
|
|
|
|
*/
|
|
|
|
public function listGetWidget($definition = null)
|
|
|
|
{
|
2014-10-11 11:58:20 +02:00
|
|
|
if (!$definition) {
|
2014-10-11 18:06:14 +11:00
|
|
|
$definition = $this->primaryDefinition;
|
2014-10-11 11:58:20 +02:00
|
|
|
}
|
2014-10-11 18:06:14 +11:00
|
|
|
|
|
|
|
return array_get($this->listWidgets, $definition);
|
|
|
|
}
|
|
|
|
|
2015-01-27 20:02:20 +11:00
|
|
|
/**
|
|
|
|
* Returns the list results as a CSV export.
|
|
|
|
*/
|
|
|
|
public function listExportCsv($options = [], $definition = null)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Locate widget
|
|
|
|
*/
|
|
|
|
if (!count($this->listWidgets)) {
|
|
|
|
$this->makeLists();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$definition || !isset($this->listDefinitions[$definition])) {
|
|
|
|
$definition = $this->primaryDefinition;
|
|
|
|
}
|
|
|
|
|
|
|
|
$widget = $this->listWidgets[$definition];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse options
|
|
|
|
*/
|
|
|
|
$defaultOptions = [
|
|
|
|
'filename' => 'export.csv'
|
|
|
|
];
|
|
|
|
|
|
|
|
$options = array_merge($defaultOptions, $options);
|
|
|
|
extract($options);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prepare CSV
|
|
|
|
*/
|
|
|
|
$csv = Writer::createFromFileObject(new SplTempFileObject);
|
|
|
|
$csv->setNullHandlingMode(Writer::NULL_AS_EMPTY);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add headers
|
|
|
|
*/
|
|
|
|
$headers = [];
|
|
|
|
$columns = $widget->getVisibleColumns();
|
|
|
|
foreach ($columns as $column) {
|
|
|
|
$headers[] = $column->label;
|
|
|
|
}
|
|
|
|
$csv->insertOne($headers);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add records
|
|
|
|
*/
|
|
|
|
$model = $widget->prepareModel();
|
|
|
|
$results = $model->get();
|
|
|
|
foreach ($results as $result) {
|
|
|
|
$record = [];
|
|
|
|
foreach ($columns as $column) {
|
|
|
|
$record[] = $widget->getColumnValue($result, $column);
|
|
|
|
}
|
|
|
|
$csv->insertOne($record);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Output
|
|
|
|
*/
|
|
|
|
$csv->output($filename);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
|
2014-10-24 17:45:11 +11:00
|
|
|
/**
|
|
|
|
* Called before the list columns are defined.
|
|
|
|
* @param Backend\Widgets\List $host The hosting list widget
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
// public function listExtendColumnsBefore($host)
|
|
|
|
// {
|
|
|
|
// }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after the list columns are defined.
|
|
|
|
* @param Backend\Widgets\List $host The hosting list widget
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function listExtendColumns($host)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
/**
|
|
|
|
* Controller override: Extend supplied model
|
|
|
|
* @param Model $model
|
|
|
|
* @return Model
|
|
|
|
*/
|
|
|
|
public function listExtendModel($model, $definition = null)
|
|
|
|
{
|
|
|
|
return $model;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller override: Extend the query used for populating the list
|
|
|
|
* before the default query is processed.
|
|
|
|
* @param October\Rain\Database\Builder $query
|
|
|
|
*/
|
2014-10-10 22:34:57 +02:00
|
|
|
public function listExtendQueryBefore($query, $definition = null)
|
|
|
|
{
|
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller override: Extend the query used for populating the list
|
|
|
|
* after the default query is processed.
|
|
|
|
* @param October\Rain\Database\Builder $query
|
|
|
|
*/
|
2014-10-10 22:34:57 +02:00
|
|
|
public function listExtendQuery($query, $definition = null)
|
|
|
|
{
|
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2014-12-23 14:57:28 +01:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
public function listFilterExtendQuery($query, $scope)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
/**
|
|
|
|
* Returns a CSS class name for a list row (<tr class="...">).
|
|
|
|
* @param Model $record The populated model used for the column
|
|
|
|
* @param string $definition List definition (optional)
|
|
|
|
* @return string HTML view
|
|
|
|
*/
|
2014-10-10 22:34:57 +02:00
|
|
|
public function listInjectRowClass($record, $definition = null)
|
|
|
|
{
|
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replace a table column value (<td>...</td>)
|
|
|
|
* @param Model $record The populated model used for the column
|
|
|
|
* @param string $columnName The column name to override
|
|
|
|
* @param string $definition List definition (optional)
|
|
|
|
* @return string HTML view
|
|
|
|
*/
|
2014-10-10 22:34:57 +02:00
|
|
|
public function listOverrideColumnValue($record, $columnName, $definition = null)
|
|
|
|
{
|
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replace the entire table header contents (<th>...</th>) with custom HTML
|
|
|
|
* @param string $columnName The column name to override
|
|
|
|
* @param string $definition List definition (optional)
|
|
|
|
* @return string HTML view
|
|
|
|
*/
|
2014-10-10 22:34:57 +02:00
|
|
|
public function listOverrideHeaderValue($columnName, $definition = null)
|
|
|
|
{
|
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2014-10-05 15:57:55 +11:00
|
|
|
/**
|
2014-10-24 17:45:11 +11:00
|
|
|
* Static helper for extending list columns.
|
2014-10-05 15:57:55 +11:00
|
|
|
* @param callable $callback
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function extendListColumns($callback)
|
|
|
|
{
|
|
|
|
$calledClass = self::getCalledExtensionClass();
|
2014-10-10 22:34:57 +02:00
|
|
|
Event::listen('backend.list.extendColumns', function ($widget) use ($calledClass, $callback) {
|
|
|
|
if (!is_a($widget->getController(), $calledClass)) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-07 18:26:08 +11:00
|
|
|
$callback($widget, $widget->model);
|
2014-10-05 15:57:55 +11:00
|
|
|
});
|
|
|
|
}
|
2014-10-10 22:34:57 +02:00
|
|
|
}
|