TractorCow\Fluent\Extension\FluentVersionedExtension
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
Synopsis
class FluentVersionedExtension
extends FluentExtension
implements
Resettable
{
- // constants
- const SUFFIX_LIVE = '_Live';
- const SUFFIX_VERSIONS = '_Versions';
- // Inherited constants from FluentExtension
- const SUFFIX = 'Localised';
- const TRANSLATE_NONE = 'none';
- // members
- protected array $defaultVersionsFields = ;
- protected array $defaultVersionsIndexes = ;
- protected static array $idsInLocaleCache = ;
- private static boolean $prepopulate_localecontent_cache = true;
- // Inherited members from FluentExtension
- protected array $localisedFields;
- protected bool $localisedCopyActive;
- // methods
- public void augmentDatabase()
- protected void augmentDatabaseDontRequire()
- protected void augmentDatabaseRequireTable()
- public void augmentSQL()
- protected void rewriteVersionedTables()
- protected void addLocaleFallbackChain()
- protected void renameLocalisedTables()
- public void augmentWrite()
- protected string getDeleteTableTarget()
- public bool isDraftedInLocale()
- public bool isPublishedInLocale()
- public bool existsInLocale()
- public bool stagesDifferInLocale()
- protected bool isLocalisedInStage()
- public void flushCache()
- public static void reset()
- public void onPrepopulateTreeDataCache()
- public static void prepoulateIdsInLocale()
- public void updateLocalisationTabColumns()
- public void updateLocalisationTabConfig()
- // Inherited methods from FluentExtension
- public array getLocalisedFields()
- protected bool isFieldLocalised()
- public array getLocalisedTables()
- protected bool anyMatch()
- public void augmentDatabase()
- protected bool validateBaseConfig()
- protected bool validateChildConfig()
- protected void augmentDatabaseDontRequire()
- protected void augmentDatabaseRequireTable()
- public void augmentSQL()
- public void onBeforeWrite()
- public void augmentWrite()
- protected void localiseManipulationTable()
- public string getLocalisedTable()
- public string deleteTableTarget()
- protected string getDeleteTableTarget()
- protected string localiseSelect()
- protected string localiseCondition()
- protected Locale|null getDataQueryLocale()
- public void updateFluentLocalisedFields()
- protected Locale|null getRecordLocale()
- public Locale|null getSourceLocale()
- protected null|int getManipulationRecordID()
- public array Locales()
- public RecordLocale LocaleInformation()
- public array getLocaleInstances()
- public string getLinkingMode()
- public string BaseURLForLocale()
- public string LocaleLink()
- public string cacheKeyComponent()
- public void updateCMSFields()
- public void updateFluentCMSField()
- protected bool requireSavedInLocale()
- protected array detectLocalisedTableField()
- public RecordLocale getSelectedLanguage()
- public bool existsInLocale()
- protected bool findRecordInLocale()
- public void updateLocalisationTabColumns()
- public void updateLocalisationTabConfig()
- public void getLocalisedCopyActive()
- public void setLocalisedCopyActive()
- public mixed withLocalisedCopyState()
- protected void makeLocalisedCopy()
- protected bool localisedCopyNeeded()
- // Inherited methods from UsesDeletePolicy
- public void updateDeleteTables()
- // Inherited methods from FluentObjectTrait
- public abstract void updateLocalisationTabColumns()
- public abstract void updateLocalisationTabConfig()
- public array LinkedLocales()
- public void augmentDataQueryCreation()
- protected void updateFluentCMSFields()
Hierarchy
Constants
Name | Value |
---|---|
SUFFIX_LIVE | '_Live' |
SUFFIX_VERSIONS | '_Versions' |
SUFFIX | 'Localised' |
TRANSLATE_NONE | 'none' |
Members
private
- $prepopulate_localecontent_cache
—
boolean
Used to enable or disable the prepopulation of the locale content cache Defaults to true.
protected
- $defaultVersionsFields
—
array
Default version table fields. _Versions has extra Version column. - $defaultVersionsIndexes
—
array
Default version table indexes, including unique index to include Version column. - $idsInLocaleCache
—
array
Array of objectIds keyed by table (ie. stage) and locale. This knows ALL object IDs that exist in the given table and locale. - $localisedCopyActive
—
TractorCow\Fluent\Extension\bool
Global state of localised copy feature -
$localisedFields
Cache of localised fields for this model
Methods
protected
- addLocaleFallbackChain() — Update all joins to include Version as well as Locale / Record
- augmentDatabaseDontRequire()
- augmentDatabaseRequireTable()
- getDeleteTableTarget() — Decorate table to delete with _Live suffix as necessary
- isLocalisedInStage() — Check to see whether or not a record exists for a specific Locale in a specific stage.
- renameLocalisedTables() — Rename all localised tables to the "live" equivalent name (note: alias remains unchanged)
- rewriteVersionedTables() — Rewrite all joined tables
public
- augmentDatabase()
- augmentSQL() — {@inheritDoc}
- augmentWrite() — Apply versioning to write
- existsInLocale() — Check if this record exists (in either state) in this locale
- flushCache() — Clear internal static property caches
- isDraftedInLocale() — Check if this record is saved in this locale
- isPublishedInLocale() — Check if this record is published in this locale
- onPrepopulateTreeDataCache() — Hook into {@link Hierarchy::prepopulateTreeDataCache}.
- prepoulateIdsInLocale() — Prepopulate the cache of IDs in a locale, to optimise batch calls to isLocalisedInStage.
- reset()
- stagesDifferInLocale() — Check if this record has modifications in this locale Fluent friendly version of @see Versioned::stagesDiffer()
- updateLocalisationTabColumns()
- updateLocalisationTabConfig() — Add versioning extensions for gridfield
Inherited from TractorCow\Fluent\Extension\FluentExtension
protected
- anyMatch() — Helper function to check if the value given is present in any of the patterns.
- augmentDatabaseDontRequire()
- augmentDatabaseRequireTable() — Require the given localisation table
- detectLocalisedTableField() — Detect a localised field within a SQL fragment.
- findRecordInLocale() — 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.
- getDataQueryLocale() — Get current locale from given dataquery
- getDeleteTableTarget() — Get real table name for deleting records (Note: Must have all table replacements applied)
- getManipulationRecordID() — Extract the RecordID value for the given write
- getRecordLocale() — Get locale this record was originally queried from, or belongs to
- isFieldLocalised() — Check if a field is marked for localisation
- localiseCondition() — Generate a where fragment based on a field with a fallback.
- localiseManipulationTable() — Localise a database manipluation from one table to another
- localiseSelect() — Generates a select fragment based on a field with a fallback
- localisedCopyNeeded() — Determine if localised copy is needed
- makeLocalisedCopy() — Duplicate related objects based on configuration Provides an extension hook for custom duplication
- requireSavedInLocale() — Require that this record is saved in the given locale for it to be visible
- validateBaseConfig() — Ensure only one instance of this extension is applied to this class
- validateChildConfig() — Non-base classes should never have fluent applied; Do this at the root only!
public
- BaseURLForLocale() — Determine the baseurl within a specified $locale.
- LocaleInformation() — Retrieves information about this object in the specified locale
- LocaleLink()
- Locales() — Templatable list of all locale information for this record
- augmentDatabase()
- augmentSQL()
- augmentWrite() — {@inheritDoc}
- cacheKeyComponent() — Ensure has_one cache is segmented by locale
- deleteTableTarget() — Public accessor for getDeleteTableTarget
- existsInLocale() — Check if this record exists (in either state) in this locale
- getLinkingMode() — Return the linking mode for the current locale and object
- getLocaleInstances() — Get list of locales where record is localised in
- getLocalisedCopyActive()
- getLocalisedFields() — Get list of fields that are localised
- getLocalisedTable() — Get the localised table name with the localised suffix and optionally with a locale suffix for aliases
- getLocalisedTables() — Get all database tables in the class ancestry and their respective translatable fields
- getSelectedLanguage() — Returns the selected language
- getSourceLocale() — Returns the source locale that will display the content for this record
- 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.
- setLocalisedCopyActive()
- updateCMSFields()
- updateFluentCMSField() — Add fluent tooltip to given field.
- updateFluentLocalisedFields() — Add / refresh fluent badges to all localised fields.
- updateLocalisationTabColumns()
- updateLocalisationTabConfig() — Add copy actions to each locale
- withLocalisedCopyState() — Localised copy global state manipulation useful for disabling localised copy feature in parts of the code
Inherited from TractorCow\Fluent\Model\Delete\UsesDeletePolicy
public
- updateDeleteTables() — Override delete behaviour.
Inherited from TractorCow\Fluent\Extension\Traits\FluentObjectTrait
protected
- updateFluentCMSFields() — Update CMS fields for fluent objects.
public
- LinkedLocales() — Gets list of all Locale dataobjects, linked to this record
- augmentDataQueryCreation() — Amend freshly created DataQuery objects with the current locale and frontend status
- updateLocalisationTabColumns() — Add additional columns to localisation table
- updateLocalisationTabConfig() — Add additional configs to localisation table