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",
"prefer-stable": true,
"require": {
"dnadesign/silverstripe-elemental": ">=3.0",
"silverstripe/vendor-plugin": "^1.0"
"php": "^8.1",
"silverstripe/cms": "^5.0",
"dnadesign/silverstripe-elemental": "^5.0",
"silverstripe/vendor-plugin": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"silverstripe/recipe-testing": "^3",
"squizlabs/php_codesniffer": "^3.0"
},
"extra": {

View File

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

View File

@ -11,6 +11,14 @@
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

@ -9,25 +9,22 @@ use SilverStripe\Control\Controller;
use SilverStripe\Core\Extension;
/**
* Class BaseElementCMSEditLinkExtension
*
* BaseElement can be nested, CMSEditLink() needs to be updated to reflect that
*
* @property BaseElementCMSEditLinkExtension|$this $owner
* @package DNADesign\ElementalList\Extension
*/
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

@ -7,41 +7,45 @@ use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Extensions\ElementalAreasExtension;
use SilverStripe\ORM\FieldType\DBField;
/**
* @property int $ElementsID
* @method ElementalArea Elements()
*/
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');
}
@ -49,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';
@ -62,7 +66,7 @@ class ElementList extends BaseElement
*
* @return string
*/
public function getOwnedAreaRelationName()
public function getOwnedAreaRelationName(): string
{
$has_one = $this->config()->get('has_one');
@ -75,7 +79,7 @@ class ElementList extends BaseElement
return 'Elements';
}
public function inlineEditable()
public function inlineEditable(): bool
{
return false;
}

View File

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