-
Notifications
You must be signed in to change notification settings - Fork 0
/
leanorm-cli-config-dist.php
75 lines (52 loc) · 3.79 KB
/
leanorm-cli-config-dist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
$pdo_opts = include __DIR__ . DIRECTORY_SEPARATOR . 'pdo.php';
return [
'pdo' => $pdo_opts,
'namespace' => 'Rotexsoft\\PhpOrmBenchmarks\\LeanOrm\\Blog', // Root Namespace classes will belong to. E.g. 'App\\DataSource'. Null means no namespace.
'directory' => './benchmark-code/lean-orm-files', // Absolute or relative path to where classes are to be written
'custom_templates_directory' => null, // Absolute or relative path to a direcory containing template files named
// TypesModel.php.tpl, TypesCollection.php.tpl & TypeRecord.php.tpl
'tables_to_skip' => ['phinxlog'], // List of tables to skip generating classes for
'collection_class_to_extend' => '\\LeanOrm\\Model\\Collection', // Class that all collection classes should extend
'model_class_to_extend' => '\\LeanOrm\\Model', // Class that all model classes should extend
'record_class_to_extend' => '\\LeanOrm\\Model\\Record', // Class that all record classes should extend
'created_timestamp_column_name' => 'date_created', // Name of a column in each table whose value will be updated with the time each row gets inserted
'updated_timestamp_column_name' => 'm_timestamp', // Name of a column in each table whose value will be updated with the time each row gets updated
'store_table_col_metadata_array_in_file' => true, // if true, a file containing table metadata info will be generated and included in each model class
'table_name_to_record_class_prefix_transformer' => // A callback that accepts a db table name, modifies it & returns the modified value that will be used to substitute {{{RECORD_CLASS_NAME_PREFIX}}} in template files
function(string $tableName): string {
$inflector = \ICanBoogie\Inflector::get('en');
$txtSeparatedWithSpaces = $inflector->titleize($tableName);
if(str_contains($txtSeparatedWithSpaces, ' ')) {
$words = explode(' ', $txtSeparatedWithSpaces);
$singularizedWordsCamelCased = '';
foreach ($words as $word) {
$singularizedWordsCamelCased .=
strlen($word) > 1
? $inflector->singularize($word)
: $word;
}
} else {
$singularizedWordsCamelCased = $inflector->singularize($txtSeparatedWithSpaces);
}
return $singularizedWordsCamelCased;
},
'table_name_to_collection_and_model_class_prefix_transformer' => // A callback that accepts a db table name, modifies it & returns the modified value that will be used to substitute {{{MODEL_OR_COLLECTION_CLASS_NAME_PREFIX}}} in template files
function(string $tableName): string {
$inflector = \ICanBoogie\Inflector::get('en');
$txtSeparatedWithSpaces = $inflector->titleize($tableName);
if(str_contains($txtSeparatedWithSpaces, ' ')) {
$words = explode(' ', $txtSeparatedWithSpaces);
$pluralizedWordsCamelCased = '';
foreach ($words as $word) {
$pluralizedWordsCamelCased .=
strlen($word) > 1
? $inflector->pluralize($word)
: $word;
}
} else {
$pluralizedWordsCamelCased = $inflector->pluralize($txtSeparatedWithSpaces);
}
return $pluralizedWordsCamelCased;
},
];