Compare commits

...

3 Commits

Author SHA1 Message Date
Melissa Wu bd27f327d6
Add support for Silverstripe 5 (#30) 2023-03-01 12:14:19 +13:00
Chris Penny 065e7b3a80
Merge pull request #31 from silverstripeltd/pull/github-actions
MNT: Move from Travis to Github Actions. Update min dependencies
2023-03-01 10:17:23 +13:00
Chris Penny ef5eeee3c9 MNT: Move from Travis to Github Actions. Update min dependencies 2023-03-01 10:08:57 +13:00
9 changed files with 59 additions and 67 deletions

12
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
ci:
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
with:
js: false

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

View File

@ -1,35 +0,0 @@
language: php
env:
global:
- COMPOSER_ROOT_VERSION=1.x-dev
matrix:
include:
- php: 5.6
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
- php: 7.0
env: DB=PGSQL PHPUNIT_TEST=1
- php: 7.0
env: DB=MYSQL PHPUNIT_TEST=1
- php: 7.1
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
before_script:
# Init PHP
- phpenv rehash
- phpenv config-rm xdebug.ini
# Install composer dependencies
- composer validate
- composer require silverstripe/recipe-cms 1.0.x-dev --no-update
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src/ tests/ ; fi
after_success:
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi

View File

@ -11,11 +11,14 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
"require": { "require": {
"dnadesign/silverstripe-elemental": ">=3.0", "php": "^8.1",
"silverstripe/vendor-plugin": "^1.0" "silverstripe/cms": "^5.0",
"dnadesign/silverstripe-elemental": "^5.0",
"silverstripe/vendor-plugin": "^2.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "^9.5",
"silverstripe/recipe-testing": "^3",
"squizlabs/php_codesniffer": "^3.0" "squizlabs/php_codesniffer": "^3.0"
}, },
"extra": { "extra": {

View File

@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true"> <phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
<testsuite name="Default"> <testsuites>
<directory>tests/php</directory> <testsuite name="Default">
</testsuite> <directory>tests</directory>
</testsuite>
</testsuites>
<filter> <filter>
<whitelist addUncoveredFilesFromWhitelist="true"> <whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory> <directory suffix=".php">src/</directory>
<exclude> <exclude>
<directory suffix=".php">tests/php</directory> <directory suffix=".php">tests/</directory>
</exclude> </exclude>
</whitelist> </whitelist>
</filter> </filter>

View File

@ -8,9 +8,17 @@
## Introduction ## 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. 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 ## Installation
``` ```

View File

@ -9,25 +9,22 @@ use SilverStripe\Control\Controller;
use SilverStripe\Core\Extension; use SilverStripe\Core\Extension;
/** /**
* Class BaseElementCMSEditLinkExtension
*
* BaseElement can be nested, CMSEditLink() needs to be updated to reflect that * BaseElement can be nested, CMSEditLink() needs to be updated to reflect that
* *
* @property BaseElementCMSEditLinkExtension|$this $owner * @property BaseElementCMSEditLinkExtension|$this $owner
* @package DNADesign\ElementalList\Extension
*/ */
class BaseElementCMSEditLinkExtension extends Extension class BaseElementCMSEditLinkExtension extends Extension
{ {
/** /**
* @param string $link * @param string $link
*/ */
public function updateCMSEditLink(&$link) public function updateCMSEditLink(?string &$link): void
{ {
/** @var $owner BaseElement */ /** @var $owner BaseElement */
$owner = $this->owner; $owner = $this->owner;
$relationName = $owner->getAreaRelationName(); $relationName = $owner->getAreaRelationName();
$page = $owner->getPage(true); $page = $owner->getPage();
if (!$page) { if (!$page) {
return; return;

View File

@ -7,41 +7,45 @@ use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Extensions\ElementalAreasExtension; use DNADesign\Elemental\Extensions\ElementalAreasExtension;
use SilverStripe\ORM\FieldType\DBField; use SilverStripe\ORM\FieldType\DBField;
/**
* @property int $ElementsID
* @method ElementalArea Elements()
*/
class ElementList extends BaseElement 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 'Elements' => ElementalArea::class
]; ];
private static $owns = [ private static array $owns = [
'Elements' 'Elements'
]; ];
private static $cascade_deletes = [ private static array $cascade_deletes = [
'Elements' 'Elements'
]; ];
private static $cascade_duplicates = [ private static array $cascade_duplicates = [
'Elements' 'Elements'
]; ];
private static $extensions = [ private static array $extensions = [
ElementalAreasExtension::class 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'); return _t(__CLASS__ . '.BlockType', 'List');
} }
@ -49,7 +53,7 @@ class ElementList extends BaseElement
/** /**
* @return DBField * @return DBField
*/ */
public function getSummary() public function getSummary(): string
{ {
$count = $this->Elements()->Elements()->Count(); $count = $this->Elements()->Elements()->Count();
$suffix = $count === 1 ? 'element': 'elements'; $suffix = $count === 1 ? 'element': 'elements';
@ -62,7 +66,7 @@ class ElementList extends BaseElement
* *
* @return string * @return string
*/ */
public function getOwnedAreaRelationName() public function getOwnedAreaRelationName(): string
{ {
$has_one = $this->config()->get('has_one'); $has_one = $this->config()->get('has_one');
@ -75,7 +79,7 @@ class ElementList extends BaseElement
return 'Elements'; return 'Elements';
} }
public function inlineEditable() public function inlineEditable(): bool
{ {
return false; return false;
} }

View File

@ -7,19 +7,19 @@ use SilverStripe\Dev\SapphireTest;
class ElementListTest extends SapphireTest class ElementListTest extends SapphireTest
{ {
public function testGetRelations() public function testGetRelations(): void
{ {
$list = ElementList::create(); $list = ElementList::create();
$this->assertEquals(['Elements'], $list->getElementalRelations()); $this->assertEquals(['Elements'], $list->getElementalRelations());
} }
public function testGetCmsFields() public function testGetCmsFields(): void
{ {
// todo // todo
} }
public function testForTemplate() public function testForTemplate(): void
{ {
// todo // todo
} }