https://github.com/flxlabs/silverstripe-versionedrelations
This module provides the possibility to version a silverstripe data object's many-many relation.
https://github.com/flxlabs/silverstripe-versionedrelations
silverstripe silverstripe-data silverstripe-relations versioned
Last synced: 5 months ago
JSON representation
This module provides the possibility to version a silverstripe data object's many-many relation.
- Host: GitHub
- URL: https://github.com/flxlabs/silverstripe-versionedrelations
- Owner: flxlabs
- License: bsd-3-clause
- Created: 2017-01-29T03:53:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-21T14:07:38.000Z (about 8 years ago)
- Last Synced: 2024-08-08T16:13:51.357Z (almost 2 years ago)
- Topics: silverstripe, silverstripe-data, silverstripe-relations, versioned
- Language: PHP
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```php
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)
```php
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)
```php
class MyRelatedObjectY extends DataObject {
private static $extensions = array(
'Versioned',
'VersionedRelationsExtension',
);
private static $versioned_belongs_has_many = array(
'MainClass' => 'MainClass',
);
}
```
MyRelatedObjectZ class (has-one)
```php
class MyRelatedObjectY extends DataObject {
private static $extensions = array(
'Versioned',
'VersionedRelationsExtension',
);
private static $versioned_belongs_to = array(
'MainClass' => 'MainClass',
);
}
```
Getting the versioned relations:
```php
…
$this->getVersionedRelation('Relations');
…
```
## TODO
* Check deletion of relations and main classes
* Check Multiple Relations on same class in dot notations
* Add Silverstripe 4 compatibility