mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
5254b1865c
Used [silverstripe-upgrader](https://github.com/silverstripe/silverstripe-upgrader) to fix name-spacing for SilverStripe v4. I then alphabetically sorted the use declarations for readability. Fixes: https://github.com/silverstripe-australia/silverstripe-gridfieldextensions/issues/166.
30 lines
596 B
PHP
30 lines
596 B
PHP
<?php
|
|
|
|
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
|
|
use SilverStripe\ORM\ArrayList;
|
|
use SilverStripe\View\ArrayData;
|
|
|
|
/**
|
|
* A simple header which displays column titles.
|
|
*/
|
|
class GridFieldTitleHeader implements GridField_HTMLProvider {
|
|
|
|
public function getHTMLFragments($grid) {
|
|
$cols = new ArrayList();
|
|
|
|
foreach ($grid->getColumns() as $name) {
|
|
$meta = $grid->getColumnMetadata($name);
|
|
|
|
$cols->push(new ArrayData(array(
|
|
'Name' => $name,
|
|
'Title' => $meta['title']
|
|
)));
|
|
}
|
|
|
|
return array(
|
|
'header' => $cols->renderWith('GridFieldTitleHeader'),
|
|
);
|
|
}
|
|
|
|
}
|