From cb46e52e7fd3e7473ce6cc8ce8d14bc1d72610dd Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Wed, 14 Aug 2024 14:42:46 -0500 Subject: [PATCH] REFACTOR migrate to Silverstripe Link (#28) --- README.md | 17 +++-------------- composer.json | 7 ++++--- src/Model/HeaderImage.php | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index f7ddc52..b8cc461 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Tools to build common functionality in SilverStripe sites. ## Requirements * Silverstripe ^5 -* gorriecoe/silverstripe-linkfield ^1.0 * silvershop/silverstripe-hasonefield ^4 +* silverstripe/linkfield: ^4 * symbiote/silverstripe-gridfieldextensions ^4 * unclecheese/display-logic ^3 @@ -28,20 +28,9 @@ composer require dynamic/silverstripe-site-tools ## License See [License](license.md) -## Upgrading from version 1 +## Upgrading from version 3 -Site Tools drops `sheadawson/silverstripe-linkable` usage in favor of `gorriecoe/silverstripe-linkfield`. To avoid data loss, install the `dynamic/silverstripe-link-migrator` module as follows: - -```markdown -composer require dynamic/silverstripe-link-migrator -``` - -Then, run the task "Linkable to SilverStripe Link Migration" via `/dev/tasks`, or cli via: -```markdown -vendor/bin/sake dev/tasks/LinkableMigrationTask -``` - -This will populate all of the new Link fields with data from the old class. +This module drops `gorriecoe/silverstripe-linkfield` usage in favor of `silverstripe/linkfield`. ## Maintainers * [Dynamic](http://www.dynamicagency.com) () diff --git a/composer.json b/composer.json index 8202f5c..5a991f5 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,14 @@ } ], "require": { - "gorriecoe/silverstripe-linkfield": "^1.0", "silvershop/silverstripe-hasonefield": "^4.0", + "silverstripe/linkfield": "^4.0", "silverstripe/recipe-cms": "^5", "symbiote/silverstripe-gridfieldextensions": "^4", "unclecheese/display-logic": "^3.0" }, "require-dev": { + "dnadesign/silverstripe-elemental": "^5", "silverstripe/recipe-testing": "^3.0" }, "minimum-stability": "dev", @@ -35,8 +36,8 @@ "config": { "allow-plugins": { "composer/installers": true, - "silverstripe/vendor-plugin": true, - "silverstripe/recipe-plugin": true + "silverstripe/recipe-plugin": true, + "silverstripe/vendor-plugin": true }, "process-timeout": 600 }, diff --git a/src/Model/HeaderImage.php b/src/Model/HeaderImage.php index 95f5b7d..255f8e4 100644 --- a/src/Model/HeaderImage.php +++ b/src/Model/HeaderImage.php @@ -2,14 +2,14 @@ namespace Dynamic\SiteTools\Model; -use gorriecoe\Link\Models\Link; -use gorriecoe\LinkField\LinkField; -use SilverStripe\AssetAdmin\Forms\UploadField; use SilverStripe\Assets\Image; -use SilverStripe\CMS\Model\SiteTree; -use SilverStripe\Forms\FieldList; use SilverStripe\ORM\DataObject; +use SilverStripe\Forms\FieldList; use SilverStripe\Security\Security; +use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\LinkField\Models\Link; +use SilverStripe\LinkField\Form\LinkField; +use SilverStripe\AssetAdmin\Forms\UploadField; /** * Class \Dynamic\SiteTools\Model\HeaderImage @@ -27,6 +27,7 @@ class HeaderImage extends DataObject { /** * @var array + * @config */ private static $db = [ 'Title' => 'Varchar(255)', @@ -35,6 +36,7 @@ class HeaderImage extends DataObject /** * @var array + * @config */ private static $has_one = [ 'Page' => SiteTree::class, @@ -44,6 +46,7 @@ class HeaderImage extends DataObject /** * @var string[] + * @config */ private static $cascade_duplicates = [ 'HeaderLink', @@ -51,6 +54,7 @@ class HeaderImage extends DataObject /** * @var array + * @config */ private static $owns = [ 'Image', @@ -58,6 +62,7 @@ class HeaderImage extends DataObject /** * @var array + * @config */ private static $searchable_fields = [ 'Title', @@ -65,6 +70,7 @@ class HeaderImage extends DataObject /** * @var array + * @config */ private static $summary_fields = [ 'Image.CMSThumbnail' => 'Image', @@ -73,6 +79,7 @@ class HeaderImage extends DataObject /** * @var string + * @config */ private static $table_name = 'HeaderImage';