Skip to content

This module provides the possibility to version a silverstripe data object's many-many relation.

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
license.md
Notifications You must be signed in to change notification settings

flxlabs/silverstripe-versionedrelations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SilverStripe Versioned Relations Module

This module provides the possibility to version silverstripe data object's many-many, has-many and has-one relations.

Usage

Main class

class MyObject extends DataObject {

    private static $extensions = array(
        'Versioned',
        'VersionedRelationsExtension',
    );

    private static $versioned_many_many = array(
        'MMRelations' => 'MyRelatedObjectX',
    );
    private static $versioned_has_many = array(
        'HMRelations' => 'MyRelatedObjectY',
    );
    private static $versioned_has_one = array(
        'HORelation' => 'MyRelatedObjectZ',
    );

    // optionally add extra fields for many-many relations
    private static $many_many_extraFields = array(
        'Relations' => array(
            'MyExtra' => 'Int',
        ),
    );

}

MyRelatedObjectX class (many-many)

class MyRelatedObjectX extends DataObject {

    private static $extensions = array(
        'Versioned',
        'VersionedRelationsExtension',
    );

    private static $versioned_belongs_many_many = array(
        'MainClasses' => 'MainClass',
    );

    /*
     * NOTE:
     * If you use the betterbuttons module,
     * get rid of the versioning buttons like this:
     */
    public function getBetterButtonsActions() {

        $fieldList = FieldList::create(array(
            BetterButton_SaveAndClose::create(),
            BetterButton_Save::create(),
        ));
        return $fieldList;

    }
}

MyRelatedObjectY class (has-many)

class MyRelatedObjectY extends DataObject {

    private static $extensions = array(
        'Versioned',
        'VersionedRelationsExtension',
    );

    private static $versioned_belongs_has_many = array(
        'MainClass' => 'MainClass',
    );

}

MyRelatedObjectZ class (has-one)

class MyRelatedObjectY extends DataObject {

    private static $extensions = array(
        'Versioned',
        'VersionedRelationsExtension',
    );

    private static $versioned_belongs_to = array(
        'MainClass' => 'MainClass',
    );

}

Getting the versioned relations:

$this->getVersionedRelation('Relations');

…

TODO

  • Check deletion of relations and main classes
  • Check Multiple Relations on same class in dot notations
  • Add Silverstripe 4 compatibility

About

This module provides the possibility to version a silverstripe data object's many-many relation.

Topics

Resources

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
license.md

Stars

Watchers

Forks

Packages

No packages published