class TopPageSiteTreeExtension extends Extension (View source)

This extension must be present on pagetypes that need to support Elemental TopPage functionality.

It can be applied directly to Page, as it only takes effect in the presence of a ElementalArea.

Properties

protected T $owner

The object this extension is applied to.

from  Extension
protected array $duplicatedPages

List of pages currently undergoing duplication

protected array $duplicatedObjects

List of objects that need to udate their top page reference

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.

protected
void
onAfterWrite()

Extension point in DataObject::onAfterWrite()

protected
void
onBeforeDuplicate(SiteTree $original)

Extension point in DataObject::duplicate()

protected
void
onAfterDuplicate(SiteTree $original, bool $doWrite)

Extension point in DataObject::duplicate()

public
string|null
getDuplicationKey()

Generates a unique key for the page

public
void
addDuplicatedObject(DataObject $object)

Registers the given object to receive an updated TopPage reference after the duplication operation completes, ensuring the new Page is written to the database beforehand.

protected
string|null
getDuplicatedPageKey()

Find currently duplicated page note: this doesn't change any stored data

protected
void
initDuplication(SiteTree $original)

No description

protected
void
processDuplication(SiteTree $original, bool $written)

Update top page reference during duplication process

protected
void
processDuplicationFromOriginal()

Relevant only for duplicated object that were not written at the time of duplication

protected
void
writeDuplication(SiteTree $original)

No description

protected
void
setTopPageForElementalArea()

Elemental area is created before related page is written so we have to set top page explicitly after page is written and the relations are available

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

protected void onAfterWrite()

Extension point in DataObject::onAfterWrite()

Return Value

void

Exceptions

ValidationException

protected void onBeforeDuplicate(SiteTree $original)

Extension point in DataObject::duplicate()

Parameters

SiteTree $original

Return Value

void

protected void onAfterDuplicate(SiteTree $original, bool $doWrite)

Extension point in DataObject::duplicate()

Parameters

SiteTree $original
bool $doWrite

Return Value

void

Exceptions

ValidationException

string|null getDuplicationKey()

Generates a unique key for the page

Return Value

string|null

void addDuplicatedObject(DataObject $object)

Registers the given object to receive an updated TopPage reference after the duplication operation completes, ensuring the new Page is written to the database beforehand.

The registry uses a stack-like structure to allow accurate tracking of objects during duplication operations that include nested pages.

Parameters

DataObject $object

Return Value

void

protected string|null getDuplicatedPageKey()

Find currently duplicated page note: this doesn't change any stored data

Return Value

string|null

protected void initDuplication(SiteTree $original)

No description

Parameters

SiteTree $original

Return Value

void

protected void processDuplication(SiteTree $original, bool $written)

Update top page reference during duplication process

Parameters

SiteTree $original
bool $written

Return Value

void

Exceptions

ValidationException

protected void processDuplicationFromOriginal()

Relevant only for duplicated object that were not written at the time of duplication

Return Value

void

Exceptions

ValidationException

protected void writeDuplication(SiteTree $original)

No description

Parameters

SiteTree $original

Return Value

void

Exceptions

ValidationException

protected void setTopPageForElementalArea()

Elemental area is created before related page is written so we have to set top page explicitly after page is written and the relations are available

Return Value

void

Exceptions

ValidationException