API Replace Extension subclasses

This commit is contained in:
Steve Boyd 2024-08-29 18:22:08 +12:00
parent 8085888c3d
commit 4298c2e2c7
13 changed files with 22 additions and 31 deletions

View File

@ -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

View File

@ -4,14 +4,14 @@ namespace SilverStripe\Subsites\Extensions;
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.

View File

@ -6,14 +6,14 @@ use SilverStripe\Assets\FileNameFilter;
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

View File

@ -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;
@ -15,9 +15,9 @@ use SilverStripe\Subsites\State\SubsiteState;
*
* @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

View File

@ -8,7 +8,7 @@ use SilverStripe\Forms\CheckboxSetField;
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;
@ -24,9 +24,9 @@ use SilverStripe\Subsites\State\SubsiteState;
*
* @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'

View File

@ -6,13 +6,13 @@ use SilverStripe\Admin\AdminRootController;
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;
@ -27,10 +27,8 @@ use SilverStripe\View\Requirements;
/**
* Decorator designed to add subsites support to LeftAndMain
*
* @extends LeftAndMainExtension<LeftAndMain>
*/
class LeftAndMainSubsites extends LeftAndMainExtension
class LeftAndMainSubsites extends Extension
{
private static $allowed_actions = ['CopyToSubsite'];

View File

@ -4,7 +4,7 @@ namespace SilverStripe\Subsites\Extensions;
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;
@ -16,9 +16,9 @@ use SilverStripe\Subsites\State\SubsiteState;
*
* @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

View File

@ -16,7 +16,7 @@ use SilverStripe\Forms\FormAction;
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;
@ -37,9 +37,9 @@ use SilverStripe\VersionedAdmin\Controllers\HistoryViewerController;
* @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
@ -112,8 +112,6 @@ class SiteTreeSubsites extends DataExtension
if (!$this->owner->ID && !$this->owner->SubsiteID) {
$this->owner->SubsiteID = SubsiteState::singleton()->getSubsiteId();
}
parent::onBeforeWrite();
}
protected function updateCMSFields(FieldList $fields)

View File

@ -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';

View File

@ -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());
}

View File

@ -109,6 +109,6 @@ class LeftAndMainSubsitesTest extends FunctionalTest
/** @var LeftAndMain&LeftAndMainSubsites $leftAndMain */
$leftAndMain = new LeftAndMain();
$this->assertTrue($leftAndMain->canAccess($member));
$this->assertTrue($leftAndMain->alternateAccessCheck($member));
}
}

View File

@ -15,8 +15,6 @@ class SiteConfigSubsitesTest extends BaseSubsiteTest
$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';

View File

@ -92,7 +92,6 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
// 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()