FluentSiteTreeExtension
class FluentSiteTreeExtension extends FluentVersionedExtension (View source)
Fluent extension for SiteTree
Traits
Constants
SUFFIX |
The table suffix that will be applied to create localisation tables |
TRANSLATE_NONE |
translate config key to disable localisations for this table |
SUFFIX_LIVE |
Live table suffix |
SUFFIX_VERSIONS |
Versions table suffix |
Properties
FluentSiteTreeExtension|SiteTree | $owner | |||
protected | $localisedFields | Cache of localised fields for this model |
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 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
Called when this extension is added to a particular class
Temporarily modify the owner. The original owner is ensured to be restored
Clear the current owner, and restore extension to the state prior to the last setOwner()
Helper method to strip eval'ed arguments from a string that's passed to DataObject::$extensions or Object::add_extension().
Edit the given query object to support queries for this extension
Update the database schema as required by this extension.
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.
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.
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.
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.
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.
Define extra database fields
This function is used to provide modifications to the Validators used on a DataObject.
This function is used to provide modifications to the form used for front end forms. DataObject->getFrontEndFields()
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']
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']
Get list of fields that are localised
Check if a field is marked for localisation
Get all database tables in the class ancestry and their respective translatable fields
Helper function to check if the value given is present in any of the patterns.
Ensure only one instance of this extension is applied to this class
Non-base classes should never have fluent applied; Do this at the root only!
Require the given localisation table
Localise a database manipluation from one table to another
Amend freshly created DataQuery objects with the current locale and frontend status
Get the localised table name with the localised suffix and optionally with a locale suffix for aliases
Public accessor for getDeleteTableTarget
Decorate table to delete with _Live suffix as necessary
Generates a select fragment based on a field with a fallback
Generate a where fragment based on a field with a fallback.
Get locale this record was originally queried from, or belongs to
Returns the source locale that will display the content for this record
Extract the RecordID value for the given write
Retrieves information about this object in the specified locale
Return the linking mode for the current locale and object
Determine the baseurl within a specified $locale.
Require that this record is saved in the given locale for it to be visible
Detect a localised field within a SQL fragment.
Update all joins to include Version as well as Locale / Record
Rename all localised tables to the "live" equivalent name (note: alias remains unchanged)
Check if this record is published in this locale
Check if this record exists (in either state) in this locale
Check to see whether or not a record exists for a specific Locale in a specific stage.
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.
Hook into Hierarchy::prepopulateTreeDataCache.
Prepopulate the cache of IDs in a locale, to optimise batch calls to isLocalisedInStage.
Add the current locale's URL segment to the start of the URL
Update link to include hostname if in domain mode
Check whether the current page is exists in the current locale.
Adds a UI message to indicate whether you're editing in the default locale or not
Add the locale's URLSegment to the URL prefix for a page's URL segment field
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
setOwner(object $owner)
Set the owner of this extension.
mixed
withOwner(mixed $owner, callable $callback, array $args = [])
Temporarily modify the owner. The original owner is ensured to be restored
clearOwner()
Clear the current owner, and restore extension to the state prior to the last setOwner()
object
getOwner()
Returns the owner of this extension.
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().
static
unload_extra_statics($class, $extension)
deprecated
deprecated
No description
validate(ValidationResult $validationResult)
Hook for extension-specific validation.
augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
Edit the given query object to support queries for this extension
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
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()
Extend the owner's onAfterWrite() logic
See DataObject::onAfterWrite() for context.
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.
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.
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.
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.
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.
updateCMSFields(FieldList $fields)
No description
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.
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.
updateCMSActions(FieldList $actions)
No description
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']
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']
updateDeleteTables(array $queriedTables)
Override delete behaviour.
Hooks into {\TractorCow\Fluent\Model\Delete\DataObject::delete()}
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
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.
This function is case sensitive by default.
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
protected
localiseManipulationTable(array $manipulation, string $table, string $localeTable, array $localisedFields, Locale $locale)
Localise a database manipluation from one table to another
augmentDataQueryCreation(SQLSelect $query, DataQuery $dataQuery)
Amend freshly created DataQuery objects with the current locale and frontend status
string
getLocalisedTable(string $tableName, string $locale = '')
Get the localised table name with the localised suffix and optionally with a locale suffix for aliases
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.
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.
protected Locale|null
getDataQueryLocale(DataQuery $dataQuery = null)
Get current locale from given dataquery
protected Locale|null
getRecordLocale()
Get locale this record was originally queried from, or belongs to
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
ArrayList
Locales()
Templatable list of all locales
ArrayData
LocaleInformation(string $locale = null)
Retrieves information about this object in the specified locale
string
getLinkingMode(string $locale)
Return the linking mode for the current locale and object
string
BaseURLForLocale(string $locale)
Determine the baseurl within a specified $locale.
string
LocaleLink(string $locale)
No description
string
cacheKeyComponent()
Ensure has_one cache is segmented by locale
protected bool
requireSavedInLocale()
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.
Works with either select / sort fragments
If successful, return an array [ thetable, thefield, fqn ] Otherwise [ null, null ]
ArrayData
getSelectedLanguage()
Returns the selected language
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)
bool
isDraftedInLocale(string $locale = null)
Check if this record is saved in this locale
bool
isPublishedInLocale(string $locale = null)
Check if this record is published in this locale
bool
existsInLocale(string $locale = null)
Check if this record exists (in either state) in this locale
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.
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.
flushCache()
Clear internal static property caches
onPrepopulateTreeDataCache(DataList|array $recordList = null, array $options = [])
Hook into Hierarchy::prepopulateTreeDataCache.
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.
MetaTags(string $tags)
Add alternate links to metatags
updateRelativeLink(string $base, string $action)
Add the current locale's URL segment to the start of the URL
updateLink(string $link, string $action, string $relativeLink)
Update link to include hostname if in domain mode
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.
protected
addLocaleStatusMessage(FieldList $fields)
Adds a UI message to indicate whether you're editing in the default locale or not
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)
No description