Hi there,
currently we have to override initFeatures
of grid handlers to provide additional columns via a feature.#But this is only feasible when adding a new grid that news a separate handler.
I want to add columns via plugins so I added a hook in GridHandler::initFeatures()
protected function initFeatures($request, $args) {
$returner = array();
HookRegistry::call(strtolower_codesafe(get_class($this) . '::initFeatures'), array($this, $request, $args, &$returner));
return $returner;
}
Plugins can now register to that call and add columns via a grid feature as needed, for example:
HookRegistry::register('customformelementsgridhandler::initfeatures', array($this, 'customFormElementsGridHandlerInitFeatures'));
…
public function customFormElementsGridHandlerInitFeatures($hookName, $args)
{
$returner =& $args[3];
import('plugins.generic.customFormElementsGridIdColumn.CustomFormElementIdColumnGridFeature');
$returner[] = new CustomFormElementIdColumnGridFeature();
}
…
class CustomFormElementIdColumnGridFeature extends GridFeature {
function __construct() {
parent::__construct('idColumn');
}
//
// Hooks implementation.
//
/**
* @see GridFeature::gridInitialize()
*/
function gridInitialize($args) {
$grid = $args['grid'];
import('plugins.generic.customFormElementsGridIdColumn.CustomFormElementIdGridColumn');
$grid->addColumn(new CustomFormElementIdGridColumn());
}
}
Can we integrate these changes into the official GitHub repo? Should i create an issue and provide a pull request?
So lonG
Daniel