From bd27f327d6e9bbbd6be15a6394dc70ddd8a019a1 Mon Sep 17 00:00:00 2001 From: Melissa Wu <81267819+MelissaWu-SS@users.noreply.github.com> Date: Wed, 1 Mar 2023 12:14:19 +1300 Subject: [PATCH] Add support for Silverstripe 5 (#30) --- composer.json | 11 +++---- readme.md | 10 ++++++- .../BaseElementCMSEditLinkExtension.php | 4 +-- src/Model/ElementList.php | 30 +++++++++---------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index b5b1328..dcc5bf7 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,14 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^7.4 || ^8", - "silverstripe/cms": "^4.11", - "dnadesign/silverstripe-elemental": "^4", - "silverstripe/vendor-plugin": "^1.0" + "php": "^8.1", + "silverstripe/cms": "^5.0", + "dnadesign/silverstripe-elemental": "^5.0", + "silverstripe/vendor-plugin": "^2.0" }, "require-dev": { - "silverstripe/recipe-testing": "^2", + "phpunit/phpunit": "^9.5", + "silverstripe/recipe-testing": "^3", "squizlabs/php_codesniffer": "^3.0" }, "extra": { diff --git a/readme.md b/readme.md index c580cae..29b4a79 100644 --- a/readme.md +++ b/readme.md @@ -8,9 +8,17 @@ ## Introduction -Adds a new element for Elemental which allows for nested blocks. This block allows users to nest blocks within other +Adds a new element for Elemental which allows for nested blocks. This block allows users to nest blocks within other blocks, allowing things like columns of blocks. +## Requirements + +* Silverstripe CMS ^5.0 +* PHP ^8.1 + +For a Silverstripe CMS ^4.2 compatible version of this module, please see the [^1.1 releases](https://github.com/dnadesign/silverstripe-elemental-list/tree/1.1.0). + + ## Installation ``` diff --git a/src/Extension/BaseElementCMSEditLinkExtension.php b/src/Extension/BaseElementCMSEditLinkExtension.php index bbc0454..4d85c64 100644 --- a/src/Extension/BaseElementCMSEditLinkExtension.php +++ b/src/Extension/BaseElementCMSEditLinkExtension.php @@ -18,13 +18,13 @@ class BaseElementCMSEditLinkExtension extends Extension /** * @param string $link */ - public function updateCMSEditLink(&$link) + public function updateCMSEditLink(?string &$link): void { /** @var $owner BaseElement */ $owner = $this->owner; $relationName = $owner->getAreaRelationName(); - $page = $owner->getPage(true); + $page = $owner->getPage(); if (!$page) { return; diff --git a/src/Model/ElementList.php b/src/Model/ElementList.php index 25279fe..af14b88 100644 --- a/src/Model/ElementList.php +++ b/src/Model/ElementList.php @@ -13,39 +13,39 @@ use SilverStripe\ORM\FieldType\DBField; */ class ElementList extends BaseElement { - private static $icon = 'font-icon-block-file-list'; + private static string $icon = 'font-icon-block-file-list'; - private static $has_one = [ + private static array $has_one = [ 'Elements' => ElementalArea::class ]; - private static $owns = [ + private static array $owns = [ 'Elements' ]; - private static $cascade_deletes = [ + private static array $cascade_deletes = [ 'Elements' ]; - private static $cascade_duplicates = [ + private static array $cascade_duplicates = [ 'Elements' ]; - private static $extensions = [ + private static array $extensions = [ ElementalAreasExtension::class ]; - private static $table_name = 'ElementList'; + private static string $table_name = 'ElementList'; - private static $title = 'Group'; + private static string $title = 'Group'; - private static $description = 'Orderable list of elements'; + private static string $description = 'Orderable list of elements'; - private static $singular_name = 'list'; + private static string $singular_name = 'list'; - private static $plural_name = 'lists'; + private static string $plural_name = 'lists'; - public function getType() + public function getType(): string { return _t(__CLASS__ . '.BlockType', 'List'); } @@ -53,7 +53,7 @@ class ElementList extends BaseElement /** * @return DBField */ - public function getSummary() + public function getSummary(): string { $count = $this->Elements()->Elements()->Count(); $suffix = $count === 1 ? 'element': 'elements'; @@ -66,7 +66,7 @@ class ElementList extends BaseElement * * @return string */ - public function getOwnedAreaRelationName() + public function getOwnedAreaRelationName(): string { $has_one = $this->config()->get('has_one'); @@ -79,7 +79,7 @@ class ElementList extends BaseElement return 'Elements'; } - public function inlineEditable() + public function inlineEditable(): bool { return false; }