class FluentSiteTreeExtension extends FluentVersionedExtension (View source)

Fluent extension for SiteTree

Traits

Decorates admin areas for localised items with extra actions.

Shared functionality between both FluentExtension and FluentFilteredExtension

Constants

SUFFIX

The table suffix that will be applied to create localisation tables

TRANSLATE_NONE

translate config key to disable localisations for this table

INHERITANCE_MODE_EXACT

Content inheritance - content will be served from the following sources in this order: current locale

INHERITANCE_MODE_FALLBACK

Content inheritance - content will be served from the following sources in this order: current locale, fallback locale

INHERITANCE_MODE_ANY

Content inheritance - content will be served from the following sources in this order: current locale, fallback locale, base record

SUFFIX_LIVE

Live table suffix

SUFFIX_VERSIONS

Versions table suffix

CACHE_COMPLETE

Indicates that record is missing in this locale and the cache search for it is complete so we can avoid multiple lookups of a missing record

Properties

$owner DataObject from  UsesDeletePolicy
protected $localisedFields

Cache of localised fields for this model

from  FluentExtension
protected bool $localisedCopyActive

Global state of localised copy feature

from  FluentExtension
protected array $defaultVersionsFields

Default version table fields. _Versions has extra Version column.

from  FluentVersionedExtension
protected array $defaultVersionsIndexes

Default version table indexes, including unique index to include Version column.

from  FluentVersionedExtension
protected array $versionsCache

Cache for versions related data lookups

from  FluentVersionedExtension
protected static int[][][] $idsInLocaleCache

Array of objectIds keyed by table (ie. stage) and locale. This knows ALL object IDs that exist in the given table and locale.

from  FluentVersionedExtension

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
validate(ValidationResult $validationResult)

Hook for extension-specific validation.

public
augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)

Edit the given query object to support queries for this extension

public
augmentDatabase()

Update the database schema as required by this extension.

public
augmentWrite(array $manipulation)

Apply versioning to write

public
onBeforeWrite()

Force all changes, since we may need to cross-publish unchanged records between locales. Without this, loading a page in a different locale and pressing "save" won't actually make the record available in this locale.

public
onAfterWrite()

No description

public
onBeforeDelete()

Extend the owner's onBeforeDelete() logic

public
onAfterDelete()

Extend the owner's onAfterDelete() logic

public
requireDefaultRecords()

Extend the owner's requireDefaultRecords() logic

public
populateDefaults()

Extend the owner's populateDefaults() logic

public
onAfterBuild()

Extend the owner's onAfterBuild() logic

public
bool|null
can(Member $member)

Influence the owner's can() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

public
bool|null
canEdit(Member $member)

Influence the owner's canEdit() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

public
bool|null
canDelete(Member $member)

Influence the owner's canDelete() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

public
bool|null
canCreate(Member $member)

Influence the owner's canCreate() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

public
array
extraStatics(string $class = null, string $extension = null)

Define extra database fields

public
updateCMSFields(FieldList $fields)

No description

public
void
updateCMSCompositeValidator(CompositeValidator $compositeValidator)

This function is used to provide modifications to the Validators used on a DataObject.

public
updateFrontEndFields(FieldList $fields)

This function is used to provide modifications to the form used for front end forms. DataObject->getFrontEndFields()

public
updateCMSActions(FieldList $actions)

No description

public
updateSummaryFields(array $fields)

this function is used to provide modifications to the summary fields in CMS by the extension By default, the summaryField() of its owner will merge more fields defined in the extension's $extra_fields['summary_fields']

public
updateFieldLabels(array $labels)

this function is used to provide modifications to the fields labels in CMS by the extension By default, the fieldLabels() of its owner will merge more fields defined in the extension's $extra_fields['field_labels']

public
updateDeleteTables(array $queriedTables)

Override delete behaviour.

public
updateLocalisationTabColumns($summaryColumns)

Add additional columns to localisation table

public
updateLocalisationTabConfig(GridFieldConfig $config)

Add additional configs to localisation table

public
Locale>
LinkedLocales()

Gets list of all Locale dataobjects, linked to this record

public
augmentDataQueryCreation(SQLSelect $query, DataQuery $dataQuery)

Amend freshly created DataQuery objects with the current locale and frontend status

protected
updateFluentCMSFields(FieldList $fields)

Update CMS fields for fluent objects.

public
array
getLocalisedFields(string $class = null)

Get list of fields that are localised

protected
bool
isFieldLocalised(string $field, string $type, string $class)

Check if a field is marked for localisation

public
array
getLocalisedTables()

Get all database tables in the class ancestry and their respective translatable fields

protected
bool
anyMatch(string $value, array $patterns)

Helper function to check if the value given is present in any of the patterns.

protected
bool
validateBaseConfig()

Ensure only one instance of this extension is applied to this class

protected
bool
validateChildConfig()

Non-base classes should never have fluent applied; Do this at the root only!

protected
augmentDatabaseDontRequire($localisedTable)

No description

protected
augmentDatabaseRequireTable(string $localisedTable, array $fields, array $indexes)

Require the given localisation table

public
void
onAfterDuplicate($original, $doWrite, $relations)

If an object is duplicated also duplicate existing localised values from original to new object.

protected
void
handleClassChanged()

If an object is changed to another class, we should trigger localised copy

protected
localiseManipulationTable(array $manipulation, string $table, string $localeTable, array $localisedFields, Locale $locale)

Localise a database manipluation from one table to another

public
string
getLocalisedTable(string $tableName, string $locale = '')

Get the localised table name with the localised suffix and optionally with a locale suffix for aliases

public
string
deleteTableTarget(string $tableName, string $locale = '')

Public accessor for getDeleteTableTarget

protected
string
getDeleteTableTarget(string $tableName, string $locale = '')

Decorate table to delete with _Live suffix as necessary

protected
string
localiseSelect(string $table, string $field, Locale $locale)

Generates a select fragment based on a field with a fallback

protected
string
localiseCondition(string $table, string $field, Locale $locale)

Generate a where fragment based on a field with a fallback.

protected
Locale|null
getDataQueryLocale(DataQuery $dataQuery = null)

Get current locale from given dataquery

public
updateFluentLocalisedFields(FieldList $fields)

Add / refresh fluent badges to all localised fields.

protected
Locale|null
getRecordLocale()

Get locale this record was originally queried from, or belongs to

public
Locale|null
getSourceLocale()

Returns the source locale that will display the content for this record

protected
null|int
getManipulationRecordID(array $updates)

Extract the RecordID value for the given write

public
RecordLocale>
Locales()

Templatable list of all locale information for this record

public
LocaleInformation(string $locale = null)

Retrieves information about this object in the specified locale

public
array
getLocaleInstances()

Get list of locales where record is localised in draft mode

public
string
BaseURLForLocale(string $locale)

Determine the baseurl within a specified $locale.

public
string
cacheKeyComponent()

Ensure has_one cache is segmented by locale

public
updateFluentCMSField(FormField $field)

Add fluent tooltip to given field.

public
void
updatePreviewLink(?string $link)

Update preview link to null if the object isn't in the current locale and we can't fallback cleanly.

protected
string
getInheritanceMode()

Require that this record is saved in the given locale for it to be visible

protected
array
detectLocalisedTableField(array $tables, string $sql)

Detect a localised field within a SQL fragment.

public
getSelectedLanguage()

Returns the selected language

public
bool
existsInLocale(string $locale = null)

Check if this record exists (in either state) in this locale

protected
bool
findRecordInLocale(string $locale, string $table, int $id)

Checks whether the given record ID exists in the given locale, in the given table. Skips using the ORM because we don't need it for this call.

public
bool
getLocalisedCopyActive()

No description

public
setLocalisedCopyActive(bool $active)

No description

public
mixed
withLocalisedCopyState(callable $callback)

Localised copy global state manipulation useful for disabling localised copy feature in parts of the code

public
void
copyToLocale(string $toLocale)

Copy data object content from current locale to the target locale

protected
void
makeLocalisedCopy()

Duplicate related objects based on configuration Provides an extension hook for custom duplication

protected
bool
localisedCopyNeeded()

Determine if localised copy is needed

protected
rewriteVersionedTables(SQLSelect $query, array $tables, Locale $locale)

Rewrite all joined tables

protected
addLocaleFallbackChain(SQLSelect $query, string $tableName, Locale $locale)

Update all joins to include Version as well as Locale / Record

protected
renameLocalisedTables(SQLSelect $query, array $tables)

Rename all localised tables to the "live" equivalent name (note: alias remains unchanged)

protected
localiseVersionsLookup(SQLSelect $query, Locale $locale)

Narrow down the list of versions down to only those which are related to current locale

public
bool
isDraftedInLocale(string $locale = null)

Check if this record is saved in this locale

public
bool
isPublishedInLocale(string $locale = null)

Check if this record is published in this locale

public
bool
stagesDifferInLocale(string|null $locale = null)

Check if this record has modifications in this locale Fluent friendly version of Versioned::stagesDiffer()

protected
bool
isLocalisedInStage(string $stage, string $locale = null)

Check to see whether or not a record exists for a specific Locale in a specific stage.

public
flushCache()

Clear internal static property caches

public
void
flushVersionsCache()

No description

public static 
reset()

Reset the local cache of this object

public
onPrepopulateTreeDataCache(DataList|array $recordList = null, array $options = [])

Hook into Hierarchy::prepopulateTreeDataCache.

public static 
prepoulateIdsInLocale(string $locale, string $dataObjectClass, bool $populateLive = true, bool $populateDraft = true)

Prepopulate the cache of IDs in a locale, to optimise batch calls to isLocalisedInStage.

public
void
updateStagesDiffer(bool $stagesDiffer)

Extension point in Versioned::stagesDiffer()

public
void
updateIsArchived(bool $isArchived)

Localise archived state Extension point in Versioned::isArchived()

public
bool|null
isArchivedInLocale(string|null $locale = null)

No description

public
bool|null
hasArchiveInLocale(string $locale = null)

Check if the record has previously existed in a locale

public
void
augmentMaxVersionSubSelect(SQLSelect $subSelect, DataQuery $dataQuery, bool $shouldApplySubSelectAsCondition)

Localise max version lookup Extension point in Versioned::prepareMaxVersionSubSelect()

public
void
updatePrePopulateVersionNumberCache(array $versions, DataObject|string $class, string $stage, array|null $idList)

Localise version cache populate Extension point in Versioned::prepopulate_versionnumber_cache()

public
void
updateGetVersionNumberByStage(int|null $version, DataObject|string $class, string $stage, int $id, bool $cache)

Localise version lookup Extension point in Versioned::get_versionnumber_by_stage()

protected
array
getCurrentVersionNumbers(string $class, string $stage, array|null $ids = null)

List versions for all objects in current locale (or a subset based on provided ids)

protected
int|bool|null
getVersionCacheItem(string $class, string $stage, string $locale, int $id)

No description

protected
void
setVersionCacheItem(string $class, string $stage, string $locale, mixed $key, int|null $value = 0)

No description

public
actionComplete(Form $form, string $message)

No description

protected
updateFluentActions(FieldList $actions, DataObject $record)

Decorate actions with fluent-specific details

public
mixed
clearFluent(array $data, Form $form)

No description

public
mixed
copyFluent(array $data, Form $form)

Copy this record to other localisations (not published)

public
mixed
unpublishFluent(array $data, Form $form)

Unpublishes the current object from all locales

public
mixed
archiveFluent(array $data, Form $form)

Archives the current object from all locales (versioned)

public
mixed
deleteFluent(array $data, Form $form)

Delete the current object from all locales (non-versioned)

public
mixed
publishFluent(array $data, Form $form)

No description

public
mixed
showFluent(array $data, Form $form)

No description

public
mixed
hideFluent(array $data, Form $form)

No description

protected
inEveryLocale(callable $doSomething)

Do an action in every locale

protected
inEveryStage(callable $doSomething)

Do an action in every stage (Live first)

protected
void
updateSaveAction(FieldList $actions, DataObject $record)

Update save action based on localisation state valid states:

  • localised (localise label)
  • not localised (save label)

protected
void
updateDeleteAction(FieldList $actions, DataObject $record)

Update delete action based on localisation state valid states:

  • localised more than one locale (unlocalise label)
  • localised in one locale (delete label)
  • not localised (remove the action)

protected
void
updateInformationPanel(FieldList $actions, DataObject $record)

Information panel shows published state of a base record by default this overrides the display with the published state of the localised record

public
MetaTags(string $tags)

Add alternate links to metatags

public
bool
getLinkToXDefault()

If this is the site home page, but still has it's own non-root url, make sure we treat the root as x-default.

public
updateRelativeLink(string $base, string $action)

Add the current locale's URL segment to the start of the URL

public
updateLink(string $link, string $action, string $relativeLink)

Update link to include hostname if in domain mode

public
updateStatusFlags(array $flags)

Check whether the current page is exists in the current locale.

protected
addLocaleStatusMessage(FieldList $fields)

Adds a UI message to indicate whether you're editing in the default locale or not

protected
string|null
getLocaleStatusMessage()

No description

protected
$this
addLocalePrefixToUrlSegment(FieldList $fields)

Add the locale's URLSegment to the URL prefix for a page's URL segment field

protected
updateSavePublishActions(FieldList $actions)

Update SiteTree specific save/publish actions

protected
void
updateRestoreAction(FieldList $actions)

Restore action needs to be removed if there is no version to revert to

protected
void
updateModifiedFlag(array $flags)

Update modified flag to reflect localised record instead of base record It doesn't make sense to have modified flag if page is not localised in current locale

protected
void
updateArchivedFlag(array $flags)

Localise archived flag - remove archived flag if there is content on other locales

protected
void
updateNoSourceFlag(array $flags)

Add a flag which indicates that a page has content in other locale but the content is not being inherited

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

validate(ValidationResult $validationResult)

Hook for extension-specific validation.

Parameters

ValidationResult $validationResult

Local validation result

Exceptions

ValidationException

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

Edit the given query object to support queries for this extension

Parameters

SQLSelect $query

Query to augment.

DataQuery $dataQuery

Container DataQuery for this SQLSelect

augmentDatabase()

Update the database schema as required by this extension.

When duplicating a table's structure, remember to duplicate the create options as well. See Versioned->augmentDatabase for an example.

augmentWrite(array $manipulation)

Apply versioning to write

Parameters

array $manipulation

Array of operations to augment.

onBeforeWrite()

Force all changes, since we may need to cross-publish unchanged records between locales. Without this, loading a page in a different locale and pressing "save" won't actually make the record available in this locale.

onAfterWrite()

No description

Exceptions

ValidationException

onBeforeDelete()

Extend the owner's onBeforeDelete() logic

See DataObject::onBeforeDelete() for context.

onAfterDelete()

Extend the owner's onAfterDelete() logic

See DataObject::onAfterDelete() for context.

requireDefaultRecords()

Extend the owner's requireDefaultRecords() logic

See DataObject::requireDefaultRecords() for context.

populateDefaults()

Extend the owner's populateDefaults() logic

See DataObject::populateDefaults() for context.

onAfterBuild()

Extend the owner's onAfterBuild() logic

See DataObject::onAfterBuild() for context.

bool|null can(Member $member)

Influence the owner's can() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

See DataObject::can()} and {@link DataObject::extendedCan() for context.

Parameters

Member $member

Return Value

bool|null

bool|null canEdit(Member $member)

Influence the owner's canEdit() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

See DataObject::canEdit()} and {@link DataObject::extendedCan() for context.

Parameters

Member $member

Return Value

bool|null

bool|null canDelete(Member $member)

Influence the owner's canDelete() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

See DataObject::canDelete()} and {@link DataObject::extendedCan() for context.

Parameters

Member $member

Return Value

bool|null

bool|null canCreate(Member $member)

Influence the owner's canCreate() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.

See DataObject::canCreate()} and {@link DataObject::extendedCan() for context.

Parameters

Member $member

Return Value

bool|null

array extraStatics(string $class = null, string $extension = null)

Define extra database fields

Return a map where the keys are db, has_one, etc, and the values are additional fields/relations to be defined.

Parameters

string $class

since this method might be called on the class directly

string $extension

since this can help to extract parameters to help set indexes

Return Value

array

Returns a map where the keys are db, has_one, etc, and the values are additional fields/relations to be defined.

updateCMSFields(FieldList $fields)

No description

Parameters

FieldList $fields

FieldList with a contained TabSet

void updateCMSCompositeValidator(CompositeValidator $compositeValidator)

This function is used to provide modifications to the Validators used on a DataObject.

Caution: Use CompositeValidator->addValidator() to add Validators.

Parameters

CompositeValidator $compositeValidator

Return Value

void

updateFrontEndFields(FieldList $fields)

This function is used to provide modifications to the form used for front end forms. DataObject->getFrontEndFields()

Caution: Use FieldList->push() to add fields.

Parameters

FieldList $fields

FieldList without TabSet nesting

updateCMSActions(FieldList $actions)

No description

Parameters

FieldList $actions FieldList

updateSummaryFields(array $fields)

this function is used to provide modifications to the summary fields in CMS by the extension By default, the summaryField() of its owner will merge more fields defined in the extension's $extra_fields['summary_fields']

Parameters

array $fields

Array of field names

updateFieldLabels(array $labels)

this function is used to provide modifications to the fields labels in CMS by the extension By default, the fieldLabels() of its owner will merge more fields defined in the extension's $extra_fields['field_labels']

Parameters

array $labels

Array of field labels

updateDeleteTables(array $queriedTables)

Override delete behaviour.

Hooks into {\TractorCow\Fluent\Model\Delete\DataObject::delete()}

Parameters

array $queriedTables

abstract updateLocalisationTabColumns($summaryColumns)

Add additional columns to localisation table

Parameters

$summaryColumns

See also

\TractorCow\Fluent\Extension\Traits\self::updateFluentCMSFields()

abstract updateLocalisationTabConfig(GridFieldConfig $config)

Add additional configs to localisation table

Parameters

GridFieldConfig $config

Locale> LinkedLocales()

Gets list of all Locale dataobjects, linked to this record

Return Value

Locale>

See also

Locale::RecordLocale

augmentDataQueryCreation(SQLSelect $query, DataQuery $dataQuery)

Amend freshly created DataQuery objects with the current locale and frontend status

Parameters

SQLSelect $query
DataQuery $dataQuery

protected updateFluentCMSFields(FieldList $fields)

Update CMS fields for fluent objects.

These fields are added in addition to those added by specific extensions

Parameters

FieldList $fields

array getLocalisedFields(string $class = null)

Get list of fields that are localised

Parameters

string $class

Class to get fields for (if parent)

Return Value

array

protected bool isFieldLocalised(string $field, string $type, string $class)

Check if a field is marked for localisation

Parameters

string $field

Field name

string $type

Field type

string $class

Class this field is defined in

Return Value

bool

array getLocalisedTables()

Get all database tables in the class ancestry and their respective translatable fields

Return Value

array

protected bool anyMatch(string $value, array $patterns)

Helper function to check if the value given is present in any of the patterns.

This function is case sensitive by default.

Parameters

string $value

A string value to check against, potentially with parameters (E.g. 'Varchar(1023)')

array $patterns

A list of strings, some of which may be regular expressions

Return Value

bool

True if this $value is present in any of the $patterns

protected bool validateBaseConfig()

Ensure only one instance of this extension is applied to this class

Return Value

bool

protected bool validateChildConfig()

Non-base classes should never have fluent applied; Do this at the root only!

Return Value

bool

protected augmentDatabaseDontRequire($localisedTable)

No description

Parameters

$localisedTable

protected augmentDatabaseRequireTable(string $localisedTable, array $fields, array $indexes)

Require the given localisation table

Parameters

string $localisedTable
array $fields
array $indexes

void onAfterDuplicate($original, $doWrite, $relations)

If an object is duplicated also duplicate existing localised values from original to new object.

Parameters

$original
$doWrite
$relations

Return Value

void

protected void handleClassChanged()

If an object is changed to another class, we should trigger localised copy

Return Value

void

Exceptions

ValidationException

protected localiseManipulationTable(array $manipulation, string $table, string $localeTable, array $localisedFields, Locale $locale)

Localise a database manipluation from one table to another

Parameters

array $manipulation
string $table

Table in manipulation to copy from

string $localeTable

Table to copy manipulation to

array $localisedFields

List of fields to filter write to

Locale $locale

string getLocalisedTable(string $tableName, string $locale = '')

Get the localised table name with the localised suffix and optionally with a locale suffix for aliases

Parameters

string $tableName
string $locale

Return Value

string

string deleteTableTarget(string $tableName, string $locale = '')

Public accessor for getDeleteTableTarget

Parameters

string $tableName
string $locale

Return Value

string

protected string getDeleteTableTarget(string $tableName, string $locale = '')

Decorate table to delete with _Live suffix as necessary

Parameters

string $tableName
string $locale

If passed, this is the locale we wish to delete in. If empty this is the root table

Return Value

string

protected string localiseSelect(string $table, string $field, Locale $locale)

Generates a select fragment based on a field with a fallback

Parameters

string $table
string $field
Locale $locale

Return Value

string

Select fragment

protected string localiseCondition(string $table, string $field, Locale $locale)

Generate a where fragment based on a field with a fallback.

This will be used as a search replacement in all where conditions matching the "Table"."Field" name. Note that unlike localiseSelect, this uses a simple COLASECLE() for performance and to reduce overall query size.

Parameters

string $table
string $field
Locale $locale

Return Value

string

Localised where replacement

protected Locale|null getDataQueryLocale(DataQuery $dataQuery = null)

Get current locale from given dataquery

Parameters

DataQuery $dataQuery

Return Value

Locale|null

updateFluentLocalisedFields(FieldList $fields)

Add / refresh fluent badges to all localised fields.

Note: Idempotent and safe to call multiple times

Parameters

FieldList $fields

protected Locale|null getRecordLocale()

Get locale this record was originally queried from, or belongs to

Return Value

Locale|null

Locale|null getSourceLocale()

Returns the source locale that will display the content for this record

Return Value

Locale|null

protected null|int getManipulationRecordID(array $updates)

Extract the RecordID value for the given write

Parameters

array $updates

Updates for the current table

Return Value

null|int

Record ID, or null if not found

RecordLocale> Locales()

Templatable list of all locale information for this record

Return Value

RecordLocale>

RecordLocale LocaleInformation(string $locale = null)

Retrieves information about this object in the specified locale

Parameters

string $locale

The locale (code) information to request, or null to use the default locale

Return Value

RecordLocale

array getLocaleInstances()

Get list of locales where record is localised in draft mode

Return Value

array

string BaseURLForLocale(string $locale)

Determine the baseurl within a specified $locale.

Parameters

string $locale Locale

Return Value

string

string cacheKeyComponent()

Ensure has_one cache is segmented by locale

Return Value

string

updateFluentCMSField(FormField $field)

Add fluent tooltip to given field.

You can use this to add fluent tag to custom fields.

Parameters

FormField $field

Update preview link to null if the object isn't in the current locale and we can't fallback cleanly.

Parameters

?string $link

Return Value

void

protected string getInheritanceMode()

Require that this record is saved in the given locale for it to be visible

Return Value

string

protected array detectLocalisedTableField(array $tables, string $sql)

Detect a localised field within a SQL fragment.

Works with either select / sort fragments

If successful, return an array [ thetable, thefield, fqn ] Otherwise [ null, null ]

Parameters

array $tables

Map of known table and nested fields to search

string $sql

The SQL string to inspect

Return Value

array

Three item array with table and field and a flag for whether the fragment is fully quolified

RecordLocale getSelectedLanguage()

Returns the selected language

Return Value

RecordLocale

bool existsInLocale(string $locale = null)

Check if this record exists (in either state) in this locale

Parameters

string $locale

Return Value

bool

protected bool findRecordInLocale(string $locale, string $table, int $id)

Checks whether the given record ID exists in the given locale, in the given table. Skips using the ORM because we don't need it for this call.

Parameters

string $locale
string $table
int $id

Return Value

bool

bool getLocalisedCopyActive()

No description

Return Value

bool

DataObject setLocalisedCopyActive(bool $active)

No description

Parameters

bool $active

Return Value

DataObject

mixed withLocalisedCopyState(callable $callback)

Localised copy global state manipulation useful for disabling localised copy feature in parts of the code

Parameters

callable $callback

Return Value

mixed

void copyToLocale(string $toLocale)

Copy data object content from current locale to the target locale

Parameters

string $toLocale

Return Value

void

Exceptions

ValidationException

protected void makeLocalisedCopy()

Duplicate related objects based on configuration Provides an extension hook for custom duplication

Return Value

void

protected bool localisedCopyNeeded()

Determine if localised copy is needed

Return Value

bool

protected rewriteVersionedTables(SQLSelect $query, array $tables, Locale $locale)

Rewrite all joined tables

Parameters

SQLSelect $query
array $tables
Locale $locale

protected addLocaleFallbackChain(SQLSelect $query, string $tableName, Locale $locale)

Update all joins to include Version as well as Locale / Record

Parameters

SQLSelect $query
string $tableName
Locale $locale

protected renameLocalisedTables(SQLSelect $query, array $tables)

Rename all localised tables to the "live" equivalent name (note: alias remains unchanged)

Parameters

SQLSelect $query
array $tables

protected localiseVersionsLookup(SQLSelect $query, Locale $locale)

Narrow down the list of versions down to only those which are related to current locale

Parameters

SQLSelect $query
Locale $locale

bool isDraftedInLocale(string $locale = null)

Check if this record is saved in this locale

Parameters

string $locale

Return Value

bool

bool isPublishedInLocale(string $locale = null)

Check if this record is published in this locale

Parameters

string $locale

Return Value

bool

bool stagesDifferInLocale(string|null $locale = null)

Check if this record has modifications in this locale Fluent friendly version of Versioned::stagesDiffer()

Parameters

string|null $locale

Return Value

bool

protected bool isLocalisedInStage(string $stage, string $locale = null)

Check to see whether or not a record exists for a specific Locale in a specific stage.

Parameters

string $stage

Version stage

string $locale

Locale to check. Defaults to current locale.

Return Value

bool

flushCache()

Clear internal static property caches

void flushVersionsCache()

No description

Return Value

void

static reset()

Reset the local cache of this object

onPrepopulateTreeDataCache(DataList|array $recordList = null, array $options = [])

Hook into Hierarchy::prepopulateTreeDataCache.

Parameters

DataList|array $recordList

The list of records to prepopulate caches for. Null for all records.

array $options

A map of hints about what should be cached. "numChildrenMethod" and "childrenMethod" are allowed keys.

static prepoulateIdsInLocale(string $locale, string $dataObjectClass, bool $populateLive = true, bool $populateDraft = true)

Prepopulate the cache of IDs in a locale, to optimise batch calls to isLocalisedInStage.

Parameters

string $locale
string $dataObjectClass
bool $populateLive
bool $populateDraft

void updateStagesDiffer(bool $stagesDiffer)

Extension point in Versioned::stagesDiffer()

Parameters

bool $stagesDiffer

Return Value

void

void updateIsArchived(bool $isArchived)

Localise archived state Extension point in Versioned::isArchived()

Parameters

bool $isArchived

Return Value

void

bool|null isArchivedInLocale(string|null $locale = null)

No description

Parameters

string|null $locale

Return Value

bool|null

bool|null hasArchiveInLocale(string $locale = null)

Check if the record has previously existed in a locale

Parameters

string $locale

Return Value

bool|null

void augmentMaxVersionSubSelect(SQLSelect $subSelect, DataQuery $dataQuery, bool $shouldApplySubSelectAsCondition)

Localise max version lookup Extension point in Versioned::prepareMaxVersionSubSelect()

Parameters

SQLSelect $subSelect
DataQuery $dataQuery
bool $shouldApplySubSelectAsCondition

Return Value

void

void updatePrePopulateVersionNumberCache(array $versions, DataObject|string $class, string $stage, array|null $idList)

Localise version cache populate Extension point in Versioned::prepopulate_versionnumber_cache()

Parameters

array $versions
DataObject|string $class
string $stage
array|null $idList

Return Value

void

void updateGetVersionNumberByStage(int|null $version, DataObject|string $class, string $stage, int $id, bool $cache)

Localise version lookup Extension point in Versioned::get_versionnumber_by_stage()

Parameters

int|null $version
DataObject|string $class
string $stage
int $id
bool $cache

Return Value

void

protected array getCurrentVersionNumbers(string $class, string $stage, array|null $ids = null)

List versions for all objects in current locale (or a subset based on provided ids)

Parameters

string $class
string $stage
array|null $ids

Return Value

array

protected int|bool|null getVersionCacheItem(string $class, string $stage, string $locale, int $id)

No description

Parameters

string $class
string $stage
string $locale
int $id

Return Value

int|bool|null

protected void setVersionCacheItem(string $class, string $stage, string $locale, mixed $key, int|null $value = 0)

No description

Parameters

string $class
string $stage
string $locale
mixed $key
int|null $value

Return Value

void

HTTPResponse|string|DBHTMLText actionComplete(Form $form, string $message)

No description

Parameters

Form $form
string $message

Return Value

HTTPResponse|string|DBHTMLText

protected updateFluentActions(FieldList $actions, DataObject $record)

Decorate actions with fluent-specific details

Parameters

FieldList $actions
DataObject $record

mixed clearFluent(array $data, Form $form)

No description

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

HTTPResponse_Exception

mixed copyFluent(array $data, Form $form)

Copy this record to other localisations (not published)

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

HTTPResponse_Exception

mixed unpublishFluent(array $data, Form $form)

Unpublishes the current object from all locales

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

HTTPResponse_Exception

mixed archiveFluent(array $data, Form $form)

Archives the current object from all locales (versioned)

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

HTTPResponse_Exception

mixed deleteFluent(array $data, Form $form)

Delete the current object from all locales (non-versioned)

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

HTTPResponse_Exception

mixed publishFluent(array $data, Form $form)

No description

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

ValidationException
HTTPResponse_Exception

mixed showFluent(array $data, Form $form)

No description

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

HTTPResponse_Exception

mixed hideFluent(array $data, Form $form)

No description

Parameters

array $data
Form $form

Return Value

mixed

Exceptions

HTTPResponse_Exception

protected inEveryLocale(callable $doSomething)

Do an action in every locale

Parameters

callable $doSomething

protected inEveryStage(callable $doSomething)

Do an action in every stage (Live first)

Parameters

callable $doSomething

protected void updateSaveAction(FieldList $actions, DataObject $record)

Update save action based on localisation state valid states:

  • localised (localise label)
  • not localised (save label)

Parameters

FieldList $actions
DataObject $record

Return Value

void

protected void updateDeleteAction(FieldList $actions, DataObject $record)

Update delete action based on localisation state valid states:

  • localised more than one locale (unlocalise label)
  • localised in one locale (delete label)
  • not localised (remove the action)

Parameters

FieldList $actions
DataObject $record

Return Value

void

protected void updateInformationPanel(FieldList $actions, DataObject $record)

Information panel shows published state of a base record by default this overrides the display with the published state of the localised record

Parameters

FieldList $actions
DataObject $record

Return Value

void

MetaTags(string $tags)

Add alternate links to metatags

Parameters

string $tags

bool getLinkToXDefault()

If this is the site home page, but still has it's own non-root url, make sure we treat the root as x-default.

Return Value

bool

Add the current locale's URL segment to the start of the URL

Parameters

string $base
string $action

Update link to include hostname if in domain mode

Parameters

string $link

root-relative url (includes baseurl)

string $action
string $relativeLink

updateStatusFlags(array $flags)

Check whether the current page is exists in the current locale.

If it is invisible then we add a class to show it slightly greyed out in the site tree.

Parameters

array $flags

protected addLocaleStatusMessage(FieldList $fields)

Adds a UI message to indicate whether you're editing in the default locale or not

Parameters

FieldList $fields

protected string|null getLocaleStatusMessage()

No description

Return Value

string|null

protected $this addLocalePrefixToUrlSegment(FieldList $fields)

Add the locale's URLSegment to the URL prefix for a page's URL segment field

Parameters

FieldList $fields

Return Value

$this

protected updateSavePublishActions(FieldList $actions)

Update SiteTree specific save/publish actions

Parameters

FieldList $actions

protected void updateRestoreAction(FieldList $actions)

Restore action needs to be removed if there is no version to revert to

Parameters

FieldList $actions

Return Value

void

protected void updateModifiedFlag(array $flags)

Update modified flag to reflect localised record instead of base record It doesn't make sense to have modified flag if page is not localised in current locale

Parameters

array $flags

Return Value

void

protected void updateArchivedFlag(array $flags)

Localise archived flag - remove archived flag if there is content on other locales

Parameters

array $flags

Return Value

void

protected void updateNoSourceFlag(array $flags)

Add a flag which indicates that a page has content in other locale but the content is not being inherited

Parameters

array $flags

Return Value

void