TractorCow\Fluent\Extension\FluentExtension
Basic fluent extension
When determining whether a field is localised, the following config options are checked in order:
- translate (uninherited, for each class in the chain)
- field_exclude
- field_include
- data_exclude
- data_include
Synopsis
class FluentExtension
extends DataExtension
{
- // constants
- const SUFFIX = 'Localised';
- const TRANSLATE_NONE = 'none';
- // members
- private static array $db_for_localised_table = ;
- private static array $indexes_for_localised_table = ;
- private static array|string $translate = ;
- private static array $field_include = ;
- private static array $field_exclude = ;
- private static array $data_include = ;
- private static array $data_exclude = ;
- private static bool $copy_to_locale_enabled = true;
- private static bool $copy_from_locale_enabled = true;
- private static bool $batch_actions_enabled = true;
- private static array $localised_copy = ;
- protected array $localisedFields = ;
- protected bool $localisedCopyActive = true;
- // methods
- 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
Extends
- SilverStripe\ORM\DataExtension
Uses
Constants
Name | Value |
---|---|
SUFFIX | 'Localised' |
TRANSLATE_NONE | 'none' |
Members
private
- $batch_actions_enabled
—
TractorCow\Fluent\Extension\bool
Enable batch actions in the edit form - $copy_from_locale_enabled
—
TractorCow\Fluent\Extension\bool
Enable copy from locale action in the localisation manager - $copy_to_locale_enabled
—
TractorCow\Fluent\Extension\bool
Enable copy to locale action in the localisation manager - $data_exclude
—
array
Filter blacklist of field types to localise. - $data_include
—
Filter whitelist of field types to localise Note: Blacklist takes priority over whitelist. - $db_for_localised_table
—
array
DB fields to be used added in when creating a localised version of the owner's table - $field_exclude
—
array
Filter blacklist of fields to localise. - $field_include
—
array
Filter whitelist of fields to localise. - $indexes_for_localised_table
—
array
Indexes to create on a localised version of the owner's table - $localised_copy
—
array
Localised copy duplication config example use: related object needs to be duplicated into the new locale config syntax: <relation_name> => <relation_id> - $translate
—
TractorCow\Fluent\Extension\array|string
List of fields to translate for this record
protected
- $localisedCopyActive
—
TractorCow\Fluent\Extension\bool
Global state of localised copy feature -
$localisedFields
Cache of localised fields for this model
Methods
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