From 5f526fb6c1caad34c652d4f52afa660827a641ed Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 27 Sep 2023 09:42:17 +1300 Subject: [PATCH] ENH Add versioning to Link --- README.md | 12 ++++++++++++ _config.php | 1 - src/Models/Link.php | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 90fa633f..134bc3d3 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,18 @@ class Page extends SiteTree 'HasOneLink' => Link::class, ]; + private static array $owns = [ + 'HasOneLink' + ]; + + private static array $cascade_deletess = [ + 'HasOneLink' + ]; + + private static array $cascade_duplicatess = [ + 'HasOneLink' + ]; + public function getCMSFields() { $fields = parent::getCMSFields(); diff --git a/_config.php b/_config.php index 9e519d4a..71c7914c 100644 --- a/_config.php +++ b/_config.php @@ -5,5 +5,4 @@ // Avoid creating global variables call_user_func(function () { - }); diff --git a/src/Models/Link.php b/src/Models/Link.php index 87d2de0f..809ccc23 100644 --- a/src/Models/Link.php +++ b/src/Models/Link.php @@ -16,6 +16,7 @@ use SilverStripe\ORM\DataObject; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\View\Requirements; +use SilverStripe\Versioned\Versioned; /** * A Link Data Object. This class should be a subclass, and you should never directly interact with a plain Link @@ -32,6 +33,10 @@ class Link extends DataObject implements JsonData, Type 'Title' => 'Varchar', 'OpenInNew' => 'Boolean', ]; + + private static array $extensions = [ + Versioned::class + ]; /** * In-memory only property used to change link type