mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
ec93c994f8
This makes this module's `GridFieldComponent` classes `Injectable`, and allows any future enhancements in the new abstract class to automatically apply without requiring additional changes in this module. The class is introduced in silverstripe/framework 4.11.0 so the dependency constraint needs to be updated. Also update docs to encourage use of dependency injection.
34 lines
826 B
PHP
34 lines
826 B
PHP
<?php
|
|
|
|
namespace Symbiote\GridFieldExtensions;
|
|
|
|
use SilverStripe\Forms\GridField\AbstractGridFieldComponent;
|
|
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
|
|
use SilverStripe\ORM\ArrayList;
|
|
use SilverStripe\View\ArrayData;
|
|
|
|
/**
|
|
* A simple header which displays column titles.
|
|
*/
|
|
class GridFieldTitleHeader extends AbstractGridFieldComponent implements GridField_HTMLProvider
|
|
{
|
|
|
|
public function getHTMLFragments($grid)
|
|
{
|
|
$cols = ArrayList::create();
|
|
|
|
foreach ($grid->getColumns() as $name) {
|
|
$meta = $grid->getColumnMetadata($name);
|
|
|
|
$cols->push(ArrayData::create(array(
|
|
'Name' => $name,
|
|
'Title' => $meta['title']
|
|
)));
|
|
}
|
|
|
|
return array(
|
|
'header' => $cols->renderWith(__CLASS__)
|
|
);
|
|
}
|
|
}
|