From 2723be924fa872c6e7f0805535cf8a398b29794b Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Fri, 17 Oct 2025 11:33:27 -0500 Subject: [PATCH 1/5] Add SilverStripe 6 compatibility - Upgrade dependencies to SilverStripe 6 compatible versions - dnadesign/silverstripe-elemental ^6.0 - silverstripe/linkfield ^5.0 - silvershop/silverstripe-hasonefield ^5.0 - unclecheese/display-logic ^4.0 - Add PHPStan static analysis with level 4 - Add PHPStan ignore comments for runtime-available methods - Update dev dependencies for testing and code quality --- composer.json | 14 ++++++++------ phpstan.neon | 7 +++++++ src/Model/BaseElementObject.php | 7 +++++-- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 phpstan.neon diff --git a/composer.json b/composer.json index a284a25..b218572 100644 --- a/composer.json +++ b/composer.json @@ -17,14 +17,16 @@ } ], "require": { - "dnadesign/silverstripe-elemental": "^5", - "silvershop/silverstripe-hasonefield": "^4", - "silverstripe/linkfield": "^4.0", - "unclecheese/display-logic": "^3" + "dnadesign/silverstripe-elemental": "^6.0", + "silvershop/silverstripe-hasonefield": "^5.0", + "silverstripe/linkfield": "^5.0", + "unclecheese/display-logic": "^4.0" }, "require-dev": { - "silverstripe/recipe-testing": "^3", - "silverstripe/frameworktest": "^1" + "cambis/silverstan": "^2.1", + "silverstripe/recipe-testing": "^4.0", + "squizlabs/php_codesniffer": "^3.7", + "phpstan/extension-installer": "^1.4" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..ad43fef --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,7 @@ +parameters: + level: 4 + treatPhpDocTypesAsCertain: false + paths: + - src + ignoreErrors: + # SilverStripe specific ignores can be added here if needed diff --git a/src/Model/BaseElementObject.php b/src/Model/BaseElementObject.php index bf3b0e5..b0e53c4 100644 --- a/src/Model/BaseElementObject.php +++ b/src/Model/BaseElementObject.php @@ -146,10 +146,12 @@ public function getCMSFields() $fields->insertBefore('Content', $fields->dataFieldByName('ElementLink')); $image = $fields->dataFieldByName('Image') - ->setDescription(_t(__CLASS__.'.ImageDescription', 'optional. Display an image.')) - ->setFolderName('Uploads/Elements/Objects'); + ->setDescription(_t(__CLASS__.'.ImageDescription', 'optional. Display an image.')); + // @phpstan-ignore-next-line + $image->setFolderName('Uploads/Elements/Objects'); $fields->insertBefore('Content', $image); + // @phpstan-ignore-next-line $fields->dataFieldByName('Content') ->setRows(8); }); @@ -227,6 +229,7 @@ public function canDelete($member = null) } if ($page = $this->getPage()) { + // @phpstan-ignore-next-line return $page->canArchive($member); } From 05f0dc42e94379db78b5576f5c831971a5545849 Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Fri, 17 Oct 2025 11:38:19 -0500 Subject: [PATCH 2/5] Update README - remove codecov badge and expand usage documentation --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4b53da0..358512e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ a simple base dataobject to use with elements [![CI](https://github.com/dynamic/silverstripe-elemental-baseobject/actions/workflows/ci.yml/badge.svg)](https://github.com/dynamic/silverstripe-elemental-baseobject/actions/workflows/ci.yml) -[![codecov](https://codecov.io/gh/dynamic/silverstripe-elemental-baseobject/branch/master/graph/badge.svg)](https://codecov.io/gh/dynamic/silverstripe-elemental-baseobject) [![Latest Stable Version](https://poser.pugx.org/dynamic/silverstripe-elemental-baseobject/v/stable)](https://packagist.org/packages/dynamic/silverstripe-elemental-baseobject) [![Total Downloads](https://poser.pugx.org/dynamic/silverstripe-elemental-baseobject/downloads)](https://packagist.org/packages/dynamic/silverstripe-elemental-baseobject) @@ -12,8 +11,10 @@ a simple base dataobject to use with elements ## Requirements -* dnadesign/silverstripe-elemental: ^5.0 -* silverstripe/linkfield: ^4.0 +* SilverStripe ^6.0 +* dnadesign/silverstripe-elemental ^6.0 +* silverstripe/linkfield ^5.0 +* PHP ^8.1 ## Installation @@ -40,14 +41,62 @@ This will populate all of the new Link fields with data from the old class. ## Usage -A base DataObject used in the following Elemental content blocks: +`BaseElementObject` is a versioned DataObject that provides a reusable foundation for managing collections of related content within Elemental blocks. It's designed to be extended or used as a `has_many` relationship in custom Element classes. -* [Accordion](https://github.com/dynamic/silverstripe-elemental-accordion) -* [Features](https://github.com/dynamic/silverstripe-elemental-features) -* [Gallery](https://github.com/dynamic/silverstripe-elemental-gallery) -* [Promos](https://github.com/dynamic/silverstripe-elemental-promos) -* [Sponsors](https://github.com/dynamic/silverstripe-elemental-sponsors) -* [Timeline](https://github.com/dynamic/silverstripe-elemental-timeline) +### Features + +The base object includes: + +- **Title** - Text field with optional display toggle (using `TextCheckboxGroupField`) +- **Content** - HTML text area for rich content +- **Image** - Image upload with automatic organization into `Uploads/Elements/Objects` +- **Link** - Configurable call-to-action using SilverStripe LinkField +- **Versioning** - Full draft/publish workflow with GridField extensions +- **Permissions** - Inherits permissions from the current page context + +### Common Usage Pattern + +Typically used as a `has_many` relationship in Elemental blocks: + +```php +use Dynamic\BaseObject\Model\BaseElementObject; +use DNADesign\Elemental\Models\BaseElement; + +class ElementAccordion extends BaseElement +{ + private static $has_many = [ + 'Items' => BaseElementObject::class, + ]; +} +``` + +### Extending BaseElementObject + +For custom functionality, extend the class: + +```php +use Dynamic\BaseObject\Model\BaseElementObject; + +class PromoObject extends BaseElementObject +{ + private static $db = [ + 'Subtitle' => 'Varchar(255)', + ]; + + private static $table_name = 'PromoObject'; +} +``` + +### Used By + +This module serves as a dependency for several Dynamic Elemental modules: + +* [Accordion](https://github.com/dynamic/silverstripe-elemental-accordion) - Collapsible content panels +* [Features](https://github.com/dynamic/silverstripe-elemental-features) - Icon-based feature highlights +* [Gallery](https://github.com/dynamic/silverstripe-elemental-gallery) - Image galleries with captions +* [Promos](https://github.com/dynamic/silverstripe-elemental-promos) - Promotional content blocks +* [Sponsors](https://github.com/dynamic/silverstripe-elemental-sponsors) - Sponsor/partner logos +* [Timeline](https://github.com/dynamic/silverstripe-elemental-timeline) - Event timelines ## Getting more elements From f3ff1d980cc65feba62e4e57c73eea16d6ebc4aa Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Fri, 17 Oct 2025 11:43:11 -0500 Subject: [PATCH 3/5] Remove outdated upgrade section from README --- README.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/README.md b/README.md index 358512e..dd723e6 100644 --- a/README.md +++ b/README.md @@ -24,21 +24,6 @@ a simple base dataobject to use with elements See [License](LICENSE.md) -## Upgrading from version 2 - -BaseObject 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. - ## Usage `BaseElementObject` is a versioned DataObject that provides a reusable foundation for managing collections of related content within Elemental blocks. It's designed to be extended or used as a `has_many` relationship in custom Element classes. From ffa46fd31efbf2d3b0debc21cf37a9a74da7df48 Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Fri, 17 Oct 2025 11:45:38 -0500 Subject: [PATCH 4/5] composer normalize --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index b218572..2f55aa1 100644 --- a/composer.json +++ b/composer.json @@ -24,9 +24,9 @@ }, "require-dev": { "cambis/silverstan": "^2.1", + "phpstan/extension-installer": "^1.4", "silverstripe/recipe-testing": "^4.0", - "squizlabs/php_codesniffer": "^3.7", - "phpstan/extension-installer": "^1.4" + "squizlabs/php_codesniffer": "^3.7" }, "minimum-stability": "dev", "prefer-stable": true, @@ -39,8 +39,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 } From 38965bd5795619dadc83f2ada1a7cfa9b5835f29 Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Fri, 17 Oct 2025 11:46:56 -0500 Subject: [PATCH 5/5] Fix README requirements formatting for consistency --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dd723e6..519201d 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ a simple base dataobject to use with elements ## Requirements -* SilverStripe ^6.0 -* dnadesign/silverstripe-elemental ^6.0 -* silverstripe/linkfield ^5.0 -* PHP ^8.1 +* SilverStripe: ^6.0 +* dnadesign/silverstripe-elemental: ^6.0 +* silverstripe/linkfield: ^5.0 +* PHP: ^8.1 ## Installation