CRM_Core_CodeGen_Schema
extends CRM_Core_CodeGen_BaseTask
in package
Create SQL files to create and populate a new schema.
Replaced by CRM_Core_CodeGen_PhpSchema. Delete this after civicrm-core and civix drop their references. Maybe allow grace-period of a couple months.
Table of Contents
Properties
- $locales : mixed
- $config : CRM_Core_CodeGen_Main
- $tables : mixed
Methods
- __construct() : mixed
- CRM_Core_CodeGen_Schema constructor.
- findLocales() : array<string|int, mixed>
- generateCreateSql() : mixed
- generateDropSql() : mixed
- generateLocaleDataSql() : array<string|int, mixed>
- generateNavigation() : mixed
- generateSample() : array<string|int, mixed>
- needsUpdate() : bool
- run() : mixed
- Perform the task.
- setConfig() : mixed
- TODO: this is the most rudimentary possible hack. CG config should eventually be made into a first-class object.
- extractRegex() : string|null
- Extract a single regex from a file.
- isApproxPhpMatch() : bool
- Determine if two snippets of PHP code are approximately equivalent.
Properties
$locales
public
mixed
$locales
$config
protected
CRM_Core_CodeGen_Main
$config
$tables
protected
mixed
$tables
Methods
__construct()
CRM_Core_CodeGen_Schema constructor.
public
__construct(CRM_Core_CodeGen_Main $config) : mixed
Parameters
- $config : CRM_Core_CodeGen_Main
findLocales()
public
findLocales() : array<string|int, mixed>
Return values
array<string|int, mixed>generateCreateSql()
public
generateCreateSql() : mixed
generateDropSql()
public
generateDropSql() : mixed
generateLocaleDataSql()
public
generateLocaleDataSql(string $locale) : array<string|int, mixed>
Parameters
- $locale : string
-
Ex: en_US, fr_FR
Return values
array<string|int, mixed>generateNavigation()
public
generateNavigation() : mixed
generateSample()
public
generateSample() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array(string $fileName => string $fileContent). List of files
needsUpdate()
public
needsUpdate() : bool
Return values
bool —TRUE if an update is needed.
run()
Perform the task.
public
run() : mixed
setConfig()
TODO: this is the most rudimentary possible hack. CG config should eventually be made into a first-class object.
public
setConfig(object $config) : mixed
Parameters
- $config : object
extractRegex()
Extract a single regex from a file.
protected
static extractRegex(string $file, string $regex) : string|null
Parameters
- $file : string
-
File name
- $regex : string
-
A pattern to match. Ex: "foo=([a-z]+)".
Return values
string|null —The value matched.
isApproxPhpMatch()
Determine if two snippets of PHP code are approximately equivalent.
protected
isApproxPhpMatch(mixed $actual, mixed $expected) : bool
This includes exceptions to equivalence for (a) whitespace and (b) the token "GenCodeChecksum".
This is useful for determining if someone has manually mucked with one the files. However, it's not perfect -- because whitespace changes are not detected. Hence, it's good to use in combination with another heuristic.
Parameters
- $actual : mixed
- $expected : mixed