FluentVersionedExtension
class FluentVersionedExtension extends FluentExtension implements Resettable (View source)
Extension for versioned localised objects
Important: If adding this to a custom object, this extension must be added AFTER the versioned extension.
Use yaml after
to enforce this
Traits
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
DataObject|FluentVersionedExtension | $owner | ||
static private array | $db_for_localised_table | DB fields to be used added in when creating a localised version of the owner's table |
from FluentExtension |
static private array | $indexes_for_localised_table | Indexes to create on a localised version of the owner's table |
from FluentExtension |
static private array | $field_include | Filter whitelist of fields to localise. |
from FluentExtension |
static private array | $field_exclude | Filter blacklist of fields to localise. |
from FluentExtension |
static private | $data_include | Filter whitelist of field types to localise Note: Blacklist takes priority over whitelist. |
from FluentExtension |
static private array | $data_exclude | Filter blacklist of field types to localise. |
from FluentExtension |
static private bool | $copy_to_locale_enabled | Enable copy to locale action in the localisation manager |
from FluentExtension |
static private bool | $copy_from_locale_enabled | Enable copy from locale action in the localisation manager |
from FluentExtension |
static private bool | $batch_actions_enabled | Enable batch actions in the edit form |
from FluentExtension |
static private bool | $localise_actions_enabled | Enable localise actions (copy to draft, copy & publish and Localise actions) these actions can be used to localise page content directly via main page actions |
from FluentExtension |
static private bool | $prepopulate_localecontent_cache | Used to enable or disable the prepopulation of the locale content cache Defaults to true. |
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 {@link DataObject::$extensions} or {@link Object::add_extension()}.
Invoke extension point. This will prefer explicit extend
prefixed
methods.
Edit the given query object to support queries for this extension
Update the database schema as required by this extension.
Apply versioning to write
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. {@link DataObject->getFrontEndFields()}
This is used to provide modifications to the form actions used in the CMS. {@link DataObject->getCMSActions()}.
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']
No description
Gets list of all Locale dataobjects, linked to this record
Amend freshly created DataQuery objects with the current locale and frontend status
Get list of fields that are localised
Get all database tables in the class ancestry and their respective translatable fields
Get the localised table name with the localised suffix and optionally with a locale suffix for aliases
Public accessor for getDeleteTableTarget
Returns the source locale that will display the content for this record
Templatable list of all locale information for this record
Retrieves information about this object in the specified locale
Get list of locales where record is localised in draft mode
Determine the baseurl within a specified $locale.
Check if this record exists (in either state) in this locale
Localised copy global state manipulation useful for disabling localised copy feature in parts of the code
Copy data object content from current locale to the target locale
Check if this record is saved in this locale
Check if this record is published in this locale
Check if this record has modifications in this locale Fluent friendly version of see Versioned::stagesDiffer()
Clear internal static property caches
No description
Reset the local cache of this object
Hook into {@link Hierarchy::prepopulateTreeDataCache}.
Prepopulate the cache of IDs in a locale, to optimise batch calls to isLocalisedInStage.
Extension point in see Versioned::stagesDiffer()
Localise archived state Extension point in see Versioned::isArchived()
No description
Check if the record has previously existed in a locale
Localise max version lookup Extension point in see Versioned::prepareMaxVersionSubSelect()
Localise version cache populate Extension point in see Versioned::prepopulate_versionnumber_cache()
Localise version lookup Extension point in see Versioned::get_versionnumber_by_stage()
Details
__construct()
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 {@link DataObject::$extensions} or {@link Object::add_extension()}.
mixed
invokeExtension(object $owner, string $method, array ...$arguments)
Invoke extension point. This will prefer explicit extend
prefixed
methods.
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 {@link 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()
onBeforeDelete()
Extend the owner's onBeforeDelete() logic
See {@link DataObject::onBeforeDelete()} for context.
onAfterDelete()
Extend the owner's onAfterDelete() logic
See {@link DataObject::onAfterDelete()} for context.
requireDefaultRecords()
Extend the owner's requireDefaultRecords() logic
See {@link DataObject::requireDefaultRecords()} for context.
populateDefaults()
Extend the owner's populateDefaults() logic
See {@link DataObject::populateDefaults()} for context.
onAfterBuild()
Extend the owner's onAfterBuild() logic
See {@link 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 {@link 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 {@link 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 {@link 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 {@link 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)
void
updateCMSCompositeValidator(CompositeValidator $compositeValidator)
This function is used to provide modifications to the Validators used on a DataObject.
Caution: Use {@link CompositeValidator->addValidator()} to add Validators.
updateFrontEndFields(FieldList $fields)
This function is used to provide modifications to the form used for front end forms. {@link DataObject->getFrontEndFields()}
Caution: Use {@link FieldList->push()} to add fields.
updateCMSActions(FieldList $actions)
This is used to provide modifications to the form actions used in the CMS. {@link DataObject->getCMSActions()}.
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 {see \TractorCow\Fluent\Model\Delete\DataObject::delete()}
updateLocalisationTabColumns($summaryColumns)
updateLocalisationTabConfig(GridFieldConfig $config)
Add versioning extensions for gridfield
augmentDataQueryCreation(SQLSelect $query, DataQuery $dataQuery)
Amend freshly created DataQuery objects with the current locale and frontend status
array
getLocalisedFields(string $class = null)
Get list of fields that are localised
array
getLocalisedTables()
Get all database tables in the class ancestry and their respective translatable fields
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
updateFluentLocalisedFields(FieldList $fields)
Add / refresh fluent badges to all localised fields.
Note: Idempotent and safe to call multiple times
Locale|null
getSourceLocale()
Returns the source locale that will display the content for this record
ArrayList|RecordLocale[]
Locales()
Templatable list of all locale information for this record
RecordLocale
LocaleInformation(string $locale = null)
Retrieves information about this object in the specified locale
array
getLocaleInstances()
Get list of locales where record is localised in draft mode
string
BaseURLForLocale(string $locale)
Determine the baseurl within a specified $locale.
string
cacheKeyComponent()
Ensure has_one cache is segmented by locale
updateFluentCMSField(FormField $field)
Add fluent tooltip to given field.
You can use this to add fluent tag to custom fields.
RecordLocale
getSelectedLanguage()
Returns the selected language
bool
existsInLocale(string $locale = null)
Check if this record exists (in either state) in this locale
bool
getLocalisedCopyActive()
DataObject
setLocalisedCopyActive(bool $active)
mixed
withLocalisedCopyState(callable $callback)
Localised copy global state manipulation useful for disabling localised copy feature in parts of the code
void
copyToLocale(string $toLocale)
Copy data object content from current locale to the target locale
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
stagesDifferInLocale(string|null $locale = null)
Check if this record has modifications in this locale Fluent friendly version of see Versioned::stagesDiffer()
flushCache()
Clear internal static property caches
void
flushVersionsCache()
static
reset()
Reset the local cache of this object
onPrepopulateTreeDataCache(DataList|array $recordList = null, array $options = [])
Hook into {@link 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.
void
updateStagesDiffer(bool $stagesDiffer)
Extension point in see Versioned::stagesDiffer()
void
updateIsArchived(bool $isArchived)
Localise archived state Extension point in see Versioned::isArchived()
bool|null
isArchivedInLocale(string|null $locale = null)
bool|null
hasArchiveInLocale(string $locale = null)
Check if the record has previously existed in a locale
void
augmentMaxVersionSubSelect(SQLSelect $subSelect, DataQuery $dataQuery, bool $shouldApplySubSelectAsCondition)
Localise max version lookup Extension point in see Versioned::prepareMaxVersionSubSelect()
void
updatePrePopulateVersionNumberCache(array $versions, DataObject|string $class, string $stage, array|null $idList)
Localise version cache populate Extension point in see Versioned::prepopulate_versionnumber_cache()
void
updateGetVersionNumberByStage(int|null $version, DataObject|string $class, string $stage, int $id, bool $cache)
Localise version lookup Extension point in see Versioned::get_versionnumber_by_stage()