CRM_Core_I18n_Schema
in package
Tags
Table of Contents
Methods
- addLocale() : mixed
- Add a new locale to a multi-lang db, setting its values to the current default locale.
- dropAllViews() : mixed
- Drop all views (for use by CRM_Core_DAO::dropAllTables() mostly).
- getLatestSchema() : mixed
- makeMultilingual() : mixed
- Switch database from single-lang to multi (by adding the first language and dropping the original columns).
- makeSinglelingual() : mixed
- Switch database from multi-lang back to single (by dropping additional columns and views and retaining only the selected locale).
- makeSinglelingualTable() : mixed
- Switch a given table from multi-lang to single (by retaining only the selected locale).
- rebuildMultilingualSchema() : mixed
- Rebuild multilingual indices, views and triggers (useful for upgrades)
- rewriteQuery() : string
- Rewrite SQL query to use views to access tables with localized columns.
- schemaStructureTables() : array<string|int, mixed>
- triggerInfo() : mixed
- alterTablesToSupportMultilingual() : bool
- Alter tables to the structure to support multilingual.
- createIndexQueries() : array<string|int, mixed>
- CREATE INDEX queries for a given locale and table.
- createViewQuery() : string
- CREATE VIEW query for a given locale and table.
Methods
addLocale()
Add a new locale to a multi-lang db, setting its values to the current default locale.
public
static addLocale(string $locale, string $source) : mixed
Parameters
- $locale : string
-
the new locale to add.
- $source : string
-
the locale to copy from.
dropAllViews()
Drop all views (for use by CRM_Core_DAO::dropAllTables() mostly).
public
static dropAllViews() : mixed
getLatestSchema()
public
static getLatestSchema(mixed $version) : mixed
Parameters
- $version : mixed
makeMultilingual()
Switch database from single-lang to multi (by adding the first language and dropping the original columns).
public
static makeMultilingual(string $locale) : mixed
Parameters
- $locale : string
-
the first locale to create (migrate to).
makeSinglelingual()
Switch database from multi-lang back to single (by dropping additional columns and views and retaining only the selected locale).
public
static makeSinglelingual(string $retain) : mixed
Parameters
- $retain : string
-
the locale to retain.
makeSinglelingualTable()
Switch a given table from multi-lang to single (by retaining only the selected locale).
public
static makeSinglelingualTable(string $retain, string $table[, string $class = 'CRM_Core_I18n_SchemaStructure' ][, array<string|int, mixed> $triggers = [] ]) : mixed
Parameters
- $retain : string
-
the locale to retain.
- $table : string
-
the table containing the column.
- $class : string = 'CRM_Core_I18n_SchemaStructure'
-
schema structure class to use to recreate indices.
- $triggers : array<string|int, mixed> = []
rebuildMultilingualSchema()
Rebuild multilingual indices, views and triggers (useful for upgrades)
public
static rebuildMultilingualSchema(array<string|int, mixed> $locales[, string $version = NULL ][, bool $isUpgradeMode = FALSE ]) : mixed
Parameters
- $locales : array<string|int, mixed>
-
locales to be rebuilt.
- $version : string = NULL
-
version of schema structure to use.
- $isUpgradeMode : bool = FALSE
-
Are we upgrading our database
rewriteQuery()
Rewrite SQL query to use views to access tables with localized columns.
public
static rewriteQuery(string $query) : string
Parameters
- $query : string
-
the query for rewrite.
Return values
string —the rewritten query
schemaStructureTables()
public
static schemaStructureTables([null $version = NULL ][, bool $force = FALSE ]) : array<string|int, mixed>
Parameters
- $version : null = NULL
- $force : bool = FALSE
Return values
array<string|int, mixed>triggerInfo()
public
static triggerInfo(mixed &$info[, null $tableName = NULL ]) : mixed
Parameters
- $info : mixed
- $tableName : null = NULL
alterTablesToSupportMultilingual()
Alter tables to the structure to support multilingual.
protected
static alterTablesToSupportMultilingual(string $locale) : bool
This alters the db structure to use language specific field names for localised fields and adds the relevant views.
Parameters
- $locale : string
Return values
boolcreateIndexQueries()
CREATE INDEX queries for a given locale and table.
private
static createIndexQueries(string $locale, string $table[, string $class = 'CRM_Core_I18n_SchemaStructure' ]) : array<string|int, mixed>
Parameters
- $locale : string
-
locale for which the queries should be created (null to create original indices).
- $table : string
-
table for which the queries should be created.
- $class : string = 'CRM_Core_I18n_SchemaStructure'
-
schema structure class to use.
Return values
array<string|int, mixed> —array of CREATE INDEX queries
createViewQuery()
CREATE VIEW query for a given locale and table.
private
static createViewQuery(string $locale, string $table, CRM_Core_DAO &$dao[, string $class = 'CRM_Core_I18n_SchemaStructure' ][, bool $isUpgradeMode = FALSE ]) : string
Parameters
- $locale : string
-
locale of the view.
- $table : string
-
table of the view.
- $dao : CRM_Core_DAO
-
A DAO object to run DESCRIBE queries.
- $class : string = 'CRM_Core_I18n_SchemaStructure'
-
schema structure class to use.
- $isUpgradeMode : bool = FALSE
-
Are we in upgrade mode therefore only build based off table not class
Return values
string —The generated CREATE VIEW query