Skip to content

Instantly share code, notes, and snippets.

@sommereder
Created April 7, 2017 08:17
Show Gist options
  • Save sommereder/a3d5f071eba7fa0c31d808bd7f9578a3 to your computer and use it in GitHub Desktop.
Save sommereder/a3d5f071eba7fa0c31d808bd7f9578a3 to your computer and use it in GitHub Desktop.
Gimme
<?php
class Gimme {
static function aGridField($__name, $__label, $__storage, $__numItemsPerPage = 32) {
$_gridFieldConfig = Gimme::getGridFieldConfig($__numItemsPerPage);
return new GridField($__name, $__label, $__storage, $_gridFieldConfig);
}
static function aSortableGridField($__name, $__label, $__storage, $__numItemsPerPage = 32) {
$_gridFieldConfig = Gimme::getGridFieldConfig($__numItemsPerPage);
$_gridFieldConfig->addComponent(new GridFieldSortableRows('SortID'));
return new GridField($__name, $__label, $__storage, $_gridFieldConfig);
}
static function getGridFieldConfig($__numItemsPerPage) {
$_gridFieldConfig = GridFieldConfig::create();
$_gridFieldConfig->addComponents(
new GridFieldToolbarHeader(),
new GridFieldSortableHeader(),
new GridFieldDetailForm(),
new GridFieldAddNewButton('toolbar-header-right'),
new GridFieldDataColumns(),
new GridFieldFilterHeader(),
new GridFieldViewButton(),
new GridFieldEditButton(),
new GridFieldDeleteAction(),
new GridFieldPaginator($__numItemsPerPage)
);
return $_gridFieldConfig;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment