Skip to content

Commit 55d53cb

Browse files
authored
Merge pull request #4 from nswdpc/feat-ci-files
Automated updates / review
2 parents 7b795f0 + aaa0cc6 commit 55d53cb

File tree

12 files changed

+187
-157
lines changed

12 files changed

+187
-157
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
/code-of-conduct.md export-ignore
1111
/CONTRIBUTING.md export-ignore
1212
/README.md export-ignore
13+
/.github export-ignore

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: CI
2+
3+
on:
4+
pull_request: null
5+
6+
jobs:
7+
Silverstripe:
8+
name: 'Silverstripe (bundle)'
9+
uses: nswdpc/ci-files/.github/workflows/silverstripe_53_83.yml@v-4
10+
PHPStan:
11+
name: 'PHPStan (analyse)'
12+
uses: nswdpc/ci-files/.github/workflows/phpstan.silverstripe_83.yml@v-4
13+
needs: Silverstripe

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/vendor/
33
.DS_Store
44
/.php-cs-fixer.cache
5+
/public/
6+
/composer.lock

.php-cs-fixer.dist.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Developers, see [config.yml](./_config/config.yml) for module configuration valu
3333

3434
## Maintainers
3535

36-
+ [dpcdigital@NSWDPC:~$](https://dpc.nsw.gov.au)
36+
+ PD Web Team
3737

3838

3939
## Bugtracker

composer.json

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,48 @@
1313
"authors": [
1414
{
1515
"name": "James Ellis",
16-
"homepage": "https://dpc.nsw.gov.au",
1716
"role": "Developer"
1817
}
1918
],
19+
"autoload": {
20+
"psr-4": {
21+
"NSWDPC\\Elemental\\Models\\Curator\\": [
22+
"src/Models/",
23+
"src/Models/Elements/"
24+
],
25+
"NSWDPC\\Elemental\\Extensions\\Curator\\": "src/Extensions/",
26+
"NSWDPC\\Elemental\\Controllers\\Curator\\": "src/Controllers/"
27+
}
28+
},
2029
"require": {
2130
"dnadesign/silverstripe-elemental": "^5"
2231
},
2332
"require-dev": {
2433
"phpunit/phpunit": "^9.5",
25-
"friendsofphp/php-cs-fixer": "^3"
34+
"friendsofphp/php-cs-fixer": "^3",
35+
"cambis/silverstan": "^2",
36+
"cambis/silverstripe-rector": "^2",
37+
"nswdpc/ci-files": "dev-v-4",
38+
"phpstan/phpstan": "^2",
39+
"rector/rector": "^2"
2640
},
2741
"extra": {
2842
"expose": [
2943
"client/static"
3044
]
45+
},
46+
"scripts": {
47+
"phpstan-analyse": "./vendor/bin/phpstan analyse --ansi --no-progress --no-interaction --configuration vendor/nswdpc/ci-files/phpstan/.phpstan.silverstripe.neon src/ tests/",
48+
"rector-dryrun": "./vendor/bin/rector process --dry-run --ansi --config vendor/nswdpc/ci-files/rector/.rector.silverstripe_53_83.php src/ tests/",
49+
"rector-process": "./vendor/bin/rector process --no-diffs --ansi --config vendor/nswdpc/ci-files/rector/.rector.silverstripe_53_83.php src/ tests/",
50+
"phpcsfixer-fix": "./vendor/bin/php-cs-fixer fix --ansi --no-interaction --config vendor/nswdpc/ci-files/php-cs-fixer/.php-cs-fixer.php src/ tests/"
51+
},
52+
"config": {
53+
"allow-plugins": {
54+
"composer/installers": true,
55+
"silverstripe/vendor-plugin": true,
56+
"silverstripe/recipe-plugin": true,
57+
"phpstan/extension-installer": true
58+
}
3159
}
3260
}

phpunit.xml.dist

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
2-
<testsuite name="nswdpc/silverstripe-curatorio">
3-
<directory>tests/</directory>
4-
</testsuite>
5-
<filter>
6-
<whitelist addUncoveredFilesFromWhitelist="true">
7-
<directory suffix=".php">src/</directory>
8-
<exclude>
9-
<directory suffix=".php">tests/</directory>
10-
</exclude>
11-
</whitelist>
12-
</filter>
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage includeUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
<exclude>
8+
<directory suffix=".php">tests/</directory>
9+
</exclude>
10+
</coverage>
11+
<testsuite name="nswdpc/silverstripe-curatorio">
12+
<directory>tests/</directory>
13+
</testsuite>
1314
</phpunit>

src/Controllers/CuratorFeedAdmin.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88
/**
99
* Curator Feed Admin, for editing/creating/deleting feeds
1010
*
11-
* @author james.ellis@dpc.nsw.gov.au
11+
* @author James
1212
*/
1313
class CuratorFeedAdmin extends ModelAdmin
1414
{
1515
/**
1616
* @inheritdoc
1717
*/
18-
private static $managed_models = [
18+
private static array $managed_models = [
1919
CuratorFeed::class
2020
];
2121

2222
/**
2323
* @inheritdoc
2424
*/
25-
private static $menu_title = 'Curator.io';
25+
private static string $menu_title = 'Curator.io';
2626

2727
/**
2828
* @inheritdoc
2929
*/
30-
private static $menu_icon_class = 'font-icon-block-carousel';
30+
private static string $menu_icon_class = 'font-icon-block-carousel';
3131

3232
/**
3333
* @inheritdoc
3434
*/
35-
private static $url_segment = 'curatorio';
35+
private static string $url_segment = 'curatorio';
3636
}

src/Extensions/SiteConfigExtension.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
namespace NSWDPC\Elemental\Extensions\Curator;
44

55
use NSWDPC\Elemental\Models\Curator\CuratorFeed;
6-
use Silverstripe\ORM\DataExtension;
7-
use Silverstripe\Forms\FieldList;
8-
use Silverstripe\Forms\DropdownField;
6+
use SilverStripe\ORM\DataExtension;
7+
use SilverStripe\Forms\FieldList;
8+
use SilverStripe\Forms\DropdownField;
99

1010
/**
1111
* Provide content administrators the ability to select a global site social feed
1212
* from a list of configured feeds
1313
* @author James
14+
* @property int $CuratorFeedRecordID
15+
* @method \NSWDPC\Elemental\Models\Curator\CuratorFeed CuratorFeedRecord()
16+
* @extends \SilverStripe\ORM\DataExtension<(\SilverStripe\SiteConfig\SiteConfig & static)>
1417
*/
1518
class SiteConfigExtension extends DataExtension
1619
{
17-
1820
/**
1921
* @inheritdoc
2022
*/
21-
private static $has_one = [
23+
private static array $has_one = [
2224
'CuratorFeedRecord' => CuratorFeed::class
2325
];
2426

@@ -32,7 +34,7 @@ public function updateCmsFields(FieldList $fields)
3234
[
3335
DropdownField::create(
3436
'CuratorFeedRecordID',
35-
_t(__CLASS__. '.SELECT_CURATOR_FEED', 'Select a global Curator.io feed'),
37+
_t(self::class. '.SELECT_CURATOR_FEED', 'Select a global Curator.io feed'),
3638
CuratorFeed::get()->map('ID', 'Title')
3739
)->setEmptyString('')
3840
]
@@ -42,22 +44,22 @@ public function updateCmsFields(FieldList $fields)
4244
/**
4345
* To add the field to your own SiteConfig extension, call this method
4446
* e.g $this->owner->getSocialFeedSelector()
45-
* @return DropdownField
4647
*/
47-
public function getSocialFeedSelector() : DropdownField {
48-
$field = DropdownField::create(
48+
public function getSocialFeedSelector(): DropdownField
49+
{
50+
return DropdownField::create(
4951
'CuratorFeedRecordID',
50-
_t(__CLASS__. '.SELECT_CURATOR_FEED', 'Select a global Curator.io feed'),
52+
_t(self::class. '.SELECT_CURATOR_FEED', 'Select a global Curator.io feed'),
5153
CuratorFeed::get()->map('ID', 'Title')
5254
)->setEmptyString('');
53-
return $field;
5455
}
5556

5657
/**
5758
* @return CuratorFeed|null
5859
*/
59-
public function getSocialFeedRecord() {
60-
return $this->owner->CuratorFeedRecord();
60+
public function getSocialFeedRecord()
61+
{
62+
return $this->getOwner()->CuratorFeedRecord();
6163
}
6264

6365
}

0 commit comments

Comments
 (0)