class SiteTreeSubsites extends Extension (View source)

Extension for the SiteTree object to add subsites support

Properties

protected T $owner

The object this extension is applied to.

from  Extension

Methods

public
__construct()

No description

public static 
add_to_class(string $class, string $extensionClass, mixed $args = null)

Called when this extension is added to a particular class

public
setOwner(object $owner)

Set the owner of this extension.

public
mixed
withOwner(mixed $owner, callable $callback, array $args = [])

Temporarily modify the owner. The original owner is ensured to be restored

public
clearOwner()

Clear the current owner, and restore extension to the state prior to the last setOwner()

public
T
getOwner()

Returns the owner of this extension.

public static 
string
get_classname_without_arguments(string $extensionStr)

Helper method to strip eval'ed arguments from a string that's passed to DataObject::$extensions or Object::add_extension().

public
mixed
invokeExtension(object $owner, string $method, array ...$arguments)

Invoke extension point. This will prefer explicit extend prefixed methods.

public
isMainSite()

No description

protected
augmentSQL(SQLSelect $query, DataQuery|null $dataQuery = null)

Update any requests to limit the results to the current site

protected
onBeforeWrite()

No description

protected
updateCMSFields(FieldList $fields)

No description

public
duplicateToSubsitePrep(Subsite|int $subsiteID, bool $includeChildren)

Does the basic duplication, but doesn't write anything this means we can subclass this easier and do more complex relation duplication.

protected
onBeforeDuplicate()

When duplicating a page, assign the current subsite ID from the state

public
duplicateToSubsite(Subsite|int $subsiteID = null, bool $includeChildren = false)

Create a duplicate of this page and save it to another subsite

public
duplicateSubsiteRelations(SiteTree $originalPage)

Duplicate relations using a static property to define which ones we want to duplicate

protected
alternateSiteConfig()

No description

protected
bool|null
canEdit(Member|null $member = null)

Only allow editing of a page if the member satisfies one of the following conditions:

  • Is in a group which has access to the subsite this page belongs to
  • Is in a group with edit permissions on the "main site"

protected
bool
canDelete(null $member = null)

No description

protected
bool
canAddChildren(null $member = null)

No description

protected
bool|null
canPublish(Member|null $member = null)

No description

public static 
contentcontrollerInit($controller)

Called by ContentController::init();

public
string
alternateAbsoluteLink(null $action = null)

No description

protected
string
updatePreviewLink(string $link, string|null $action = null)

Use the CMS domain for iframed CMS previews to prevent single-origin violations and SSL cert problems. Always set SubsiteID to avoid errors because a page doesn't exist on the CMS domain.

protected
string
updateMetaTags($tags) deprecated

Inject the subsite ID into the content so it can be used by frontend scripts.

protected
augmentSyncLinkTracking()

No description

protected
null|bool
augmentValidURLSegment()

Ensure that valid url segments are checked within the correct subsite of the owner object, even if the current subsiteID is set to some other subsite.

protected
cacheKeyComponent()

Return a piece of text to keep DataObject cache keys appropriately specific

protected
bool|null
canCreate(Member $member = null)

No description

void
ManyManyList() $SiteTree> CrossSubsiteLinkTracking()

No description

Subsite()

No description

Details

__construct()

No description

static add_to_class(string $class, string $extensionClass, mixed $args = null)

Called when this extension is added to a particular class

Parameters

string $class
string $extensionClass
mixed $args

setOwner(object $owner)

Set the owner of this extension.

Parameters

object $owner

The owner object

mixed withOwner(mixed $owner, callable $callback, array $args = [])

Temporarily modify the owner. The original owner is ensured to be restored

Parameters

mixed $owner

Owner to set

callable $callback

Callback to invoke

array $args

Args to pass to callback

Return Value

mixed

clearOwner()

Clear the current owner, and restore extension to the state prior to the last setOwner()

T getOwner()

Returns the owner of this extension.

Return Value

T

static string get_classname_without_arguments(string $extensionStr)

Helper method to strip eval'ed arguments from a string that's passed to DataObject::$extensions or Object::add_extension().

Parameters

string $extensionStr

E.g. "Versioned('Stage','Live')"

Return Value

string

Extension classname, e.g. "Versioned"

mixed invokeExtension(object $owner, string $method, array ...$arguments)

Invoke extension point. This will prefer explicit extend prefixed methods.

Parameters

object $owner
string $method
array ...$arguments

Return Value

mixed

isMainSite()

No description

protected augmentSQL(SQLSelect $query, DataQuery|null $dataQuery = null)

Update any requests to limit the results to the current site

Parameters

SQLSelect $query
DataQuery|null $dataQuery

protected onBeforeWrite()

No description

protected updateCMSFields(FieldList $fields)

No description

Parameters

FieldList $fields

SiteTree duplicateToSubsitePrep(Subsite|int $subsiteID, bool $includeChildren)

Does the basic duplication, but doesn't write anything this means we can subclass this easier and do more complex relation duplication.

Note that when duplicating including children, everything is written.

Parameters

Subsite|int $subsiteID
bool $includeChildren

Return Value

SiteTree

protected onBeforeDuplicate()

When duplicating a page, assign the current subsite ID from the state

SiteTree duplicateToSubsite(Subsite|int $subsiteID = null, bool $includeChildren = false)

Create a duplicate of this page and save it to another subsite

Parameters

Subsite|int $subsiteID

The Subsite to copy to, or its ID

bool $includeChildren

Whether to duplicate child pages too

Return Value

SiteTree

The duplicated page

duplicateSubsiteRelations(SiteTree $originalPage)

Duplicate relations using a static property to define which ones we want to duplicate

It may be that some relations are not diostinct to sub site so can stay whereas others may need to be duplicated

This was originally deprecated - Use the "cascade_duplicates" config API instead Ideally this would be re-deprecated

Parameters

SiteTree $originalPage

protected SiteConfig alternateSiteConfig()

No description

Return Value

SiteConfig

protected bool|null canEdit(Member|null $member = null)

Only allow editing of a page if the member satisfies one of the following conditions:

  • Is in a group which has access to the subsite this page belongs to
  • Is in a group with edit permissions on the "main site"

If there are no subsites configured yet, this logic is skipped.

Parameters

Member|null $member

Return Value

bool|null

protected bool canDelete(null $member = null)

No description

Parameters

null $member

Return Value

bool

protected bool canAddChildren(null $member = null)

No description

Parameters

null $member

Return Value

bool

protected bool|null canPublish(Member|null $member = null)

No description

Parameters

Member|null $member

Return Value

bool|null

static contentcontrollerInit($controller)

Called by ContentController::init();

Parameters

$controller

No description

Parameters

null $action

Return Value

string

Use the CMS domain for iframed CMS previews to prevent single-origin violations and SSL cert problems. Always set SubsiteID to avoid errors because a page doesn't exist on the CMS domain.

Parameters

string $link
string|null $action

Return Value

string

protected string updateMetaTags($tags) deprecated

deprecated 3.4.0 Will be renamed to updateMetaTags()

Inject the subsite ID into the content so it can be used by frontend scripts.

Parameters

$tags

Return Value

string

protected augmentSyncLinkTracking()

No description

protected null|bool augmentValidURLSegment()

Ensure that valid url segments are checked within the correct subsite of the owner object, even if the current subsiteID is set to some other subsite.

Return Value

null|bool

Either true or false, or null to not influence result

protected cacheKeyComponent()

Return a piece of text to keep DataObject cache keys appropriately specific

protected bool|null canCreate(Member $member = null)

No description

Parameters

Member $member

Return Value

bool|null

void ManyManyList() $SiteTree> CrossSubsiteLinkTracking()

No description

Parameters

) $SiteTree> CrossSubsiteLinkTracking(

Return Value

void

Subsite Subsite()

No description

Return Value

Subsite