bluehousegroup/silverstripe-data-object-version-viewer

This package is abandoned and no longer maintained. No replacement package was suggested.

Allows viewing of version history for data objects inside of the SilverStripe CMS

0.1 2017-03-10 17:51 UTC

This package is auto-updated.

Last update: 2021-12-17 08:08:10 UTC


README

Screenshot

Install with Composer

composer require bluehousegroup/silverstripe-data-object-version-viewer

Usage

  • Extend silverstripe-versioneddataobjects to add a 'History' button to a GridField or ModelAdmin
  • View, revert to, and publish a previous versions of a data object

Example code

The implementation is very similar to the versioneddataobjects module, on which this module depends.

Within your DataObject class

class Slice extends DataObject
{
	private static $db = [
		'Content' => 'Text'
	];

	private static $has_one = [
		'Parent' => 'SiteTree'
	];

	private static $extensions = [
		'Heyday\VersionedDataObjects\VersionedDataObject'
	];
}

To use VersionedDataObject records in a GridField, GridFieldDetailForm needs to be replaced with VersionedRevertDODetailsForm:

// ...

public function getCMSFields()
{
	$fields = parent::getCMSFields();

	$fields->addFieldToTab(
		'Root.Slices',
		new GridField(
			'Slices',
			'Slices',
			$this->Slices(),
			$config = GridFieldConfig_RelationEditor::create()
		)
	);

	$config->removeComponentsByType('GridFieldDetailForm');
	$config->addComponent(new VersionedRevertDODetailsForm());

	return $fields;
}

// ...

Versioned DataObjects in a ModelAdmin

class SliceAdmin extends VersionedRevertModelAdmin
{
	private static $menu_title = 'Slices';

	private static $url_segment = 'slice';

	private static $managed_models = [
		'Slice'
	];
}

Notes

This module is intended to be compatible with the betterbuttons module. Toward that end, it removes the betterbuttons's Versioning button group in order to keep in tact the buttons added by the versiondataobjects plug-in. This change affects only the forms configured with the VersionedRevertDODetailsForm extension.