heyday/silverstripe-versioneddataobjects

Provides Versioned DataObjects in SilverStripe

Installs: 2 287

Dependents: 2

Stars: 10

Watchers: 20

Forks: 5

Open Issues: 1

Language: PHP

1.1.0 2015-06-18 23:46 UTC

README

Provides Versioned DataObjects and CMS publishing buttons in SilverStripe

Installation (with composer)

$ composer require heyday/silverstripe-versioneddataobjects

Example

Versioned DataObject Example Versioned DataObject Example 2

Usage

Slice.php

class Slice extends DataObject
{
    private static $has_one = array(
        'Parent' => 'SiteTree'
    );
    private static $extensions = array(
        'VersionedDataObject'
    );
}

Page.php

class Page extends SiteTree
{
    private static $has_many = array(
        'Slices' => 'Slice'
    );
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

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

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

        return $fields;
    }
}

Unit testing

None :(

License

SilverStripe Versioned DataObjects is licensed under an MIT license