From d9402c1a472c1fb9e40aa0cc80ba3e580a070413 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 21 Aug 2024 10:11:41 +1200 Subject: [PATCH] API Replace Extension subclasses --- src/Extensions/ElementalAreaUsedOnTableExtension.php | 6 +++--- src/Extensions/ElementalAreasExtension.php | 8 +++----- src/TopPage/DataExtension.php | 6 +++--- src/TopPage/SiteTreeExtension.php | 6 ++---- tests/Src/TestElementContentExtension.php | 4 ++-- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Extensions/ElementalAreaUsedOnTableExtension.php b/src/Extensions/ElementalAreaUsedOnTableExtension.php index 3d828407..f55e24ee 100644 --- a/src/Extensions/ElementalAreaUsedOnTableExtension.php +++ b/src/Extensions/ElementalAreaUsedOnTableExtension.php @@ -3,17 +3,17 @@ namespace DNADesign\Elemental\Extensions; use SilverStripe\CMS\Model\SiteTree; -use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\ValidationException; use DNADesign\Elemental\Models\ElementalArea; use DNADesign\Elemental\Models\BaseElement; use SilverStripe\Admin\Forms\UsedOnTable; +use SilverStripe\Core\Extension; /** - * @extends DataExtension + * @extends Extension */ -class ElementalAreaUsedOnTableExtension extends DataExtension +class ElementalAreaUsedOnTableExtension extends Extension { /** * Hides ElementalArea's from the "Used On" tab when viewing files diff --git a/src/Extensions/ElementalAreasExtension.php b/src/Extensions/ElementalAreasExtension.php index 4ecfb9e6..5cc3732d 100644 --- a/src/Extensions/ElementalAreasExtension.php +++ b/src/Extensions/ElementalAreasExtension.php @@ -13,11 +13,11 @@ use SilverStripe\Core\Extensible; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\LiteralField; -use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\RelatedData\StandardRelatedDataService; use SilverStripe\Versioned\Versioned; use SilverStripe\View\ViewableData; +use SilverStripe\Core\Extension; /** * This extension handles most of the relationships between pages and element @@ -44,9 +44,9 @@ * ); * * @template T of DataObject - * @extends DataExtension + * @extends Extension */ -class ElementalAreasExtension extends DataExtension +class ElementalAreasExtension extends Extension { use Extensible; @@ -220,8 +220,6 @@ protected function updateCMSFields(FieldList $fields) */ protected function onBeforeWrite() { - parent::onBeforeWrite(); - if (!$this->supportsElemental()) { return; } diff --git a/src/TopPage/DataExtension.php b/src/TopPage/DataExtension.php index 7bb89aa3..683eda58 100644 --- a/src/TopPage/DataExtension.php +++ b/src/TopPage/DataExtension.php @@ -6,12 +6,12 @@ use DNADesign\Elemental\Models\ElementalArea; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Core\ClassInfo; -use SilverStripe\ORM\DataExtension as BaseDataExtension; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\Queries\SQLUpdate; use SilverStripe\ORM\ValidationException; use SilverStripe\View\ViewableData; use SilverStripe\Forms\FieldList; +use SilverStripe\Core\Extension; /** * Class DataExtension @@ -22,9 +22,9 @@ * @property int $TopPageID * @method SiteTree TopPage() * - * @extends BaseDataExtension + * @extends Extension */ -class DataExtension extends BaseDataExtension +class DataExtension extends Extension { /** * @config diff --git a/src/TopPage/SiteTreeExtension.php b/src/TopPage/SiteTreeExtension.php index b6124fb4..3cd2bca6 100644 --- a/src/TopPage/SiteTreeExtension.php +++ b/src/TopPage/SiteTreeExtension.php @@ -4,19 +4,17 @@ use DNADesign\Elemental\Extensions\ElementalPageExtension; use SilverStripe\CMS\Model\SiteTree; -use SilverStripe\CMS\Model\SiteTreeExtension as BaseSiteTreeExtension; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\ValidationException; +use SilverStripe\Core\Extension; /** * Class SiteTreeExtension * * This extension must be present on pagetypes that need to support Elemental TopPage functionality. * It can be applied directly to Page, as it only takes effect in the presence of a ElementalArea. - * - * @extends BaseSiteTreeExtension */ -class SiteTreeExtension extends BaseSiteTreeExtension +class SiteTreeExtension extends Extension { /** * List of pages currently undergoing duplication diff --git a/tests/Src/TestElementContentExtension.php b/tests/Src/TestElementContentExtension.php index 78bb12d7..e4b546fd 100644 --- a/tests/Src/TestElementContentExtension.php +++ b/tests/Src/TestElementContentExtension.php @@ -2,10 +2,10 @@ namespace DNADesign\Elemental\Tests\Src; -use SilverStripe\ORM\DataExtension; use SilverStripe\Dev\TestOnly; +use SilverStripe\Core\Extension; -class TestElementContentExtension extends DataExtension implements TestOnly +class TestElementContentExtension extends Extension implements TestOnly { private static $db = [ 'UnrenderedField' => 'Varchar(255)',