mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
API Replace Extension subclasses
This commit is contained in:
parent
8085888c3d
commit
4298c2e2c7
@ -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
|
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.
|
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
|
which extends various methods to add Subsite functionality some of the methods are listed below
|
||||||
|
|
||||||
### augmentSQL
|
### augmentSQL
|
||||||
|
@ -4,14 +4,14 @@ namespace SilverStripe\Subsites\Extensions;
|
|||||||
|
|
||||||
use DNADesign\Elemental\Models\BaseElement;
|
use DNADesign\Elemental\Models\BaseElement;
|
||||||
use SilverStripe\Control\HTTP;
|
use SilverStripe\Control\HTTP;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\Core\Extension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension for the BaseElement object to add subsites support for CMS previews
|
* 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.
|
* Set SubsiteID to avoid errors when a page doesn't exist on the CMS domain.
|
||||||
|
@ -6,14 +6,14 @@ use SilverStripe\Assets\FileNameFilter;
|
|||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\ErrorPage\ErrorPage;
|
use SilverStripe\ErrorPage\ErrorPage;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\Subsites\Model\Subsite;
|
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
|
* Alter file path to generated a static (static) error page file to handle error page template
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace SilverStripe\Subsites\Extensions;
|
namespace SilverStripe\Subsites\Extensions;
|
||||||
|
|
||||||
use SilverStripe\Assets\File;
|
use SilverStripe\Assets\File;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\ORM\DataQuery;
|
use SilverStripe\ORM\DataQuery;
|
||||||
use SilverStripe\ORM\Queries\SQLSelect;
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
@ -15,9 +15,9 @@ use SilverStripe\Subsites\State\SubsiteState;
|
|||||||
*
|
*
|
||||||
* @method Subsite Subsite()
|
* @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
|
* If this is set to true, all folders created will be default be considered 'global', unless set otherwise
|
||||||
|
@ -8,7 +8,7 @@ use SilverStripe\Forms\CheckboxSetField;
|
|||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\OptionsetField;
|
use SilverStripe\Forms\OptionsetField;
|
||||||
use SilverStripe\Forms\ReadonlyField;
|
use SilverStripe\Forms\ReadonlyField;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DataQuery;
|
use SilverStripe\ORM\DataQuery;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
@ -24,9 +24,9 @@ use SilverStripe\Subsites\State\SubsiteState;
|
|||||||
*
|
*
|
||||||
* @method ManyManyList<Subsite> Subsites()
|
* @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 = [
|
private static $db = [
|
||||||
'AccessAllSubsites' => 'Boolean'
|
'AccessAllSubsites' => 'Boolean'
|
||||||
|
@ -6,13 +6,13 @@ use SilverStripe\Admin\AdminRootController;
|
|||||||
use SilverStripe\Admin\CMSMenu;
|
use SilverStripe\Admin\CMSMenu;
|
||||||
use SilverStripe\Admin\CMSProfileController;
|
use SilverStripe\Admin\CMSProfileController;
|
||||||
use SilverStripe\Admin\LeftAndMain;
|
use SilverStripe\Admin\LeftAndMain;
|
||||||
use SilverStripe\Admin\LeftAndMainExtension;
|
|
||||||
use SilverStripe\CMS\Controllers\CMSPagesController;
|
use SilverStripe\CMS\Controllers\CMSPagesController;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\CMS\Controllers\CMSPageEditController;
|
use SilverStripe\CMS\Controllers\CMSPageEditController;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\Forms\HiddenField;
|
use SilverStripe\Forms\HiddenField;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
@ -27,10 +27,8 @@ use SilverStripe\View\Requirements;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorator designed to add subsites support to LeftAndMain
|
* Decorator designed to add subsites support to LeftAndMain
|
||||||
*
|
|
||||||
* @extends LeftAndMainExtension<LeftAndMain>
|
|
||||||
*/
|
*/
|
||||||
class LeftAndMainSubsites extends LeftAndMainExtension
|
class LeftAndMainSubsites extends Extension
|
||||||
{
|
{
|
||||||
private static $allowed_actions = ['CopyToSubsite'];
|
private static $allowed_actions = ['CopyToSubsite'];
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Subsites\Extensions;
|
|||||||
|
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\HiddenField;
|
use SilverStripe\Forms\HiddenField;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\ORM\DataQuery;
|
use SilverStripe\ORM\DataQuery;
|
||||||
use SilverStripe\ORM\Queries\SQLSelect;
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
use SilverStripe\SiteConfig\SiteConfig;
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
@ -16,9 +16,9 @@ use SilverStripe\Subsites\State\SubsiteState;
|
|||||||
*
|
*
|
||||||
* @method Subsite Subsite()
|
* @method Subsite Subsite()
|
||||||
*
|
*
|
||||||
* @extends DataExtension<SiteConfig&static>
|
* @extends Extension<SiteConfig&static>
|
||||||
*/
|
*/
|
||||||
class SiteConfigSubsites extends DataExtension
|
class SiteConfigSubsites extends Extension
|
||||||
{
|
{
|
||||||
private static $has_one = [
|
private static $has_one = [
|
||||||
'Subsite' => Subsite::class, // The subsite that this page belongs to
|
'Subsite' => Subsite::class, // The subsite that this page belongs to
|
||||||
|
@ -16,7 +16,7 @@ use SilverStripe\Forms\FormAction;
|
|||||||
use SilverStripe\Forms\ToggleCompositeField;
|
use SilverStripe\Forms\ToggleCompositeField;
|
||||||
use SilverStripe\i18n\i18n;
|
use SilverStripe\i18n\i18n;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DataQuery;
|
use SilverStripe\ORM\DataQuery;
|
||||||
use SilverStripe\ORM\ManyManyList;
|
use SilverStripe\ORM\ManyManyList;
|
||||||
@ -37,9 +37,9 @@ use SilverStripe\VersionedAdmin\Controllers\HistoryViewerController;
|
|||||||
* @method ManyManyList<SiteTree> CrossSubsiteLinkTracking()
|
* @method ManyManyList<SiteTree> CrossSubsiteLinkTracking()
|
||||||
* @method Subsite Subsite()
|
* @method Subsite Subsite()
|
||||||
*
|
*
|
||||||
* @extends DataExtension<SiteTree&static>
|
* @extends Extension<SiteTree&static>
|
||||||
*/
|
*/
|
||||||
class SiteTreeSubsites extends DataExtension
|
class SiteTreeSubsites extends Extension
|
||||||
{
|
{
|
||||||
private static $has_one = [
|
private static $has_one = [
|
||||||
'Subsite' => Subsite::class, // The subsite that this page belongs to
|
'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) {
|
if (!$this->owner->ID && !$this->owner->SubsiteID) {
|
||||||
$this->owner->SubsiteID = SubsiteState::singleton()->getSubsiteId();
|
$this->owner->SubsiteID = SubsiteState::singleton()->getSubsiteId();
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::onBeforeWrite();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updateCMSFields(FieldList $fields)
|
protected function updateCMSFields(FieldList $fields)
|
||||||
|
@ -17,7 +17,6 @@ class FileSubsitesTest extends BaseSubsiteTest
|
|||||||
|
|
||||||
public function testTrivialFeatures()
|
public function testTrivialFeatures()
|
||||||
{
|
{
|
||||||
$this->assertTrue(is_array(singleton(FileSubsites::class)->extraStatics()));
|
|
||||||
$file = new File();
|
$file = new File();
|
||||||
$file->Name = 'FileTitle';
|
$file->Name = 'FileTitle';
|
||||||
$file->Title = 'FileTitle';
|
$file->Title = 'FileTitle';
|
||||||
|
@ -15,7 +15,6 @@ class GroupSubsitesTest extends BaseSubsiteTest
|
|||||||
|
|
||||||
public function testTrivialFeatures()
|
public function testTrivialFeatures()
|
||||||
{
|
{
|
||||||
$this->assertIsArray(singleton(GroupSubsites::class)->extraStatics());
|
|
||||||
$this->assertIsArray(singleton(GroupSubsites::class)->providePermissions());
|
$this->assertIsArray(singleton(GroupSubsites::class)->providePermissions());
|
||||||
$this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields());
|
$this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields());
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,6 @@ class LeftAndMainSubsitesTest extends FunctionalTest
|
|||||||
|
|
||||||
/** @var LeftAndMain&LeftAndMainSubsites $leftAndMain */
|
/** @var LeftAndMain&LeftAndMainSubsites $leftAndMain */
|
||||||
$leftAndMain = new LeftAndMain();
|
$leftAndMain = new LeftAndMain();
|
||||||
$this->assertTrue($leftAndMain->canAccess($member));
|
$this->assertTrue($leftAndMain->alternateAccessCheck($member));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ class SiteConfigSubsitesTest extends BaseSubsiteTest
|
|||||||
$subsite1 = $this->objFromFixture(Subsite::class, 'domaintest1');
|
$subsite1 = $this->objFromFixture(Subsite::class, 'domaintest1');
|
||||||
$subsite2 = $this->objFromFixture(Subsite::class, 'domaintest2');
|
$subsite2 = $this->objFromFixture(Subsite::class, 'domaintest2');
|
||||||
|
|
||||||
$this->assertTrue(is_array(singleton(SiteConfigSubsites::class)->extraStatics()));
|
|
||||||
|
|
||||||
Subsite::changeSubsite(0);
|
Subsite::changeSubsite(0);
|
||||||
$sc = SiteConfig::current_site_config();
|
$sc = SiteConfig::current_site_config();
|
||||||
$sc->Title = 'RootSite';
|
$sc->Title = 'RootSite';
|
||||||
|
@ -92,7 +92,6 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
// The following assert is breaking in Translatable.
|
// The following assert is breaking in Translatable.
|
||||||
$this->assertInstanceOf(FieldList::class, singleton(SiteTree::class)->getCMSFields());
|
$this->assertInstanceOf(FieldList::class, singleton(SiteTree::class)->getCMSFields());
|
||||||
$this->assertInstanceOf(FieldList::class, singleton(SubsitesVirtualPage::class)->getCMSFields());
|
$this->assertInstanceOf(FieldList::class, singleton(SubsitesVirtualPage::class)->getCMSFields());
|
||||||
$this->assertTrue(is_array(singleton(SiteTreeSubsites::class)->extraStatics()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function errorPageLocationsProvider()
|
public function errorPageLocationsProvider()
|
||||||
|
Loading…
Reference in New Issue
Block a user