Skip to content

Commit

Permalink
Merge pull request #593 from creative-commoners/pulls/4/replace-exten…
Browse files Browse the repository at this point in the history
…sion-subclasses

API Replace Extension subclasses
  • Loading branch information
GuySartorelli authored Aug 29, 2024
2 parents 8085888 + 4298c2e commit 681043c
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/en/technical.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ page to a particular subsite.

The subsite module adds functionality to the admin section of the site to allow you to create new subsites and copy
pages between the main site and any subsites.
Subsites makes use of a DataExtension called SiteTreeSubsites to add support for subsites to the SiteTree,
Subsites makes use of an Extension called SiteTreeSubsites to add support for subsites to the SiteTree,
which extends various methods to add Subsite functionality some of the methods are listed below

### augmentSQL
Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/BaseElementSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Control\HTTP;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Core\Extension;

/**
* Extension for the BaseElement object to add subsites support for CMS previews
*
* @extends DataExtension<BaseElement>
* @extends Extension<BaseElement>
*/
class BaseElementSubsites extends DataExtension
class BaseElementSubsites extends Extension
{
/**
* Set SubsiteID to avoid errors when a page doesn't exist on the CMS domain.
Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/ErrorPageSubsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Config\Config;
use SilverStripe\ErrorPage\ErrorPage;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Core\Extension;
use SilverStripe\ORM\DataObject;
use SilverStripe\Subsites\Model\Subsite;

/**
* @extends DataExtension<ErrorPage>
* @extends Extension<ErrorPage>
*/
class ErrorPageSubsite extends DataExtension
class ErrorPageSubsite extends Extension
{
/**
* Alter file path to generated a static (static) error page file to handle error page template
Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/FileSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace SilverStripe\Subsites\Extensions;

use SilverStripe\Assets\File;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Core\Extension;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\Security\Permission;
Expand All @@ -15,9 +15,9 @@
*
* @method Subsite Subsite()
*
* @extends DataExtension<File>
* @extends Extension<File>
*/
class FileSubsites extends DataExtension
class FileSubsites extends Extension
{
/**
* If this is set to true, all folders created will be default be considered 'global', unless set otherwise
Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/GroupSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\OptionsetField;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Core\Extension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\DB;
Expand All @@ -24,9 +24,9 @@
*
* @method ManyManyList<Subsite> Subsites()
*
* @extends DataExtension<Group&static>
* @extends Extension<Group&static>
*/
class GroupSubsites extends DataExtension implements PermissionProvider
class GroupSubsites extends Extension implements PermissionProvider
{
private static $db = [
'AccessAllSubsites' => 'Boolean'
Expand Down
6 changes: 2 additions & 4 deletions src/Extensions/LeftAndMainSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
use SilverStripe\Admin\CMSMenu;
use SilverStripe\Admin\CMSProfileController;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Admin\LeftAndMainExtension;
use SilverStripe\CMS\Controllers\CMSPagesController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\HiddenField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
Expand All @@ -27,10 +27,8 @@

/**
* Decorator designed to add subsites support to LeftAndMain
*
* @extends LeftAndMainExtension<LeftAndMain>
*/
class LeftAndMainSubsites extends LeftAndMainExtension
class LeftAndMainSubsites extends Extension
{
private static $allowed_actions = ['CopyToSubsite'];

Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/SiteConfigSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HiddenField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Core\Extension;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\SiteConfig\SiteConfig;
Expand All @@ -16,9 +16,9 @@
*
* @method Subsite Subsite()
*
* @extends DataExtension<SiteConfig&static>
* @extends Extension<SiteConfig&static>
*/
class SiteConfigSubsites extends DataExtension
class SiteConfigSubsites extends Extension
{
private static $has_one = [
'Subsite' => Subsite::class, // The subsite that this page belongs to
Expand Down
8 changes: 3 additions & 5 deletions src/Extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use SilverStripe\Forms\ToggleCompositeField;
use SilverStripe\i18n\i18n;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Core\Extension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\ManyManyList;
Expand All @@ -37,9 +37,9 @@
* @method ManyManyList<SiteTree> CrossSubsiteLinkTracking()
* @method Subsite Subsite()
*
* @extends DataExtension<SiteTree&static>
* @extends Extension<SiteTree&static>
*/
class SiteTreeSubsites extends DataExtension
class SiteTreeSubsites extends Extension
{
private static $has_one = [
'Subsite' => Subsite::class, // The subsite that this page belongs to
Expand Down Expand Up @@ -112,8 +112,6 @@ protected function onBeforeWrite()
if (!$this->owner->ID && !$this->owner->SubsiteID) {
$this->owner->SubsiteID = SubsiteState::singleton()->getSubsiteId();
}

parent::onBeforeWrite();
}

protected function updateCMSFields(FieldList $fields)
Expand Down
1 change: 0 additions & 1 deletion tests/php/FileSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class FileSubsitesTest extends BaseSubsiteTest

public function testTrivialFeatures()
{
$this->assertTrue(is_array(singleton(FileSubsites::class)->extraStatics()));
$file = new File();
$file->Name = 'FileTitle';
$file->Title = 'FileTitle';
Expand Down
1 change: 0 additions & 1 deletion tests/php/GroupSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class GroupSubsitesTest extends BaseSubsiteTest

public function testTrivialFeatures()
{
$this->assertIsArray(singleton(GroupSubsites::class)->extraStatics());
$this->assertIsArray(singleton(GroupSubsites::class)->providePermissions());
$this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/LeftAndMainSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ public function testCanAccessWithPassedMember()

/** @var LeftAndMain&LeftAndMainSubsites $leftAndMain */
$leftAndMain = new LeftAndMain();
$this->assertTrue($leftAndMain->canAccess($member));
$this->assertTrue($leftAndMain->alternateAccessCheck($member));
}
}
2 changes: 0 additions & 2 deletions tests/php/SiteConfigSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function testEachSubsiteHasAUniqueSiteConfig()
$subsite1 = $this->objFromFixture(Subsite::class, 'domaintest1');
$subsite2 = $this->objFromFixture(Subsite::class, 'domaintest2');

$this->assertTrue(is_array(singleton(SiteConfigSubsites::class)->extraStatics()));

Subsite::changeSubsite(0);
$sc = SiteConfig::current_site_config();
$sc->Title = 'RootSite';
Expand Down
1 change: 0 additions & 1 deletion tests/php/SiteTreeSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public function testBasicSanity()
// The following assert is breaking in Translatable.
$this->assertInstanceOf(FieldList::class, singleton(SiteTree::class)->getCMSFields());
$this->assertInstanceOf(FieldList::class, singleton(SubsitesVirtualPage::class)->getCMSFields());
$this->assertTrue(is_array(singleton(SiteTreeSubsites::class)->extraStatics()));
}

public function errorPageLocationsProvider()
Expand Down

0 comments on commit 681043c

Please sign in to comment.