Skip to content

Commit

Permalink
API Replace Extension subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Aug 20, 2024
1 parent 3a6f722 commit 5ea69d6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 25 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

0 comments on commit 5ea69d6

Please sign in to comment.