Add support for Silverstripe 5 (#30)

This commit is contained in:
Melissa Wu 2023-03-01 12:14:19 +13:00 committed by GitHub
parent 065e7b3a80
commit bd27f327d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 23 deletions

View File

@ -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": {

View File

@ -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
```

View File

@ -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;

View File

@ -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;
}