-
Notifications
You must be signed in to change notification settings - Fork 6
/
eck.php
60 lines (55 loc) · 2.12 KB
/
eck.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
<?php
/*-------------------------------------------------------+
| CiviCRM Entity Construction Kit |
| Copyright (C) 2021 SYSTOPIA |
| Author: J. Schuppe ([email protected]) |
+--------------------------------------------------------+
| This program is released as free software under the |
| Affero GPL license. You can redistribute it and/or |
| modify it under the terms of this license which you |
| can read by viewing the included agpl.txt or online |
| at www.gnu.org/licenses/agpl.html. Removal of this |
| copyright header is strictly prohibited without |
| written permission from the original author(s). |
+--------------------------------------------------------*/
require_once 'eck.civix.php';
use CRM_Eck_ExtensionUtil as E;
/**
* Implements hook_civicrm_config().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
*/
function eck_civicrm_config(&$config) {
_eck_civix_civicrm_config($config);
}
/**
* Implements hook_civicrm_entityTypes().
*
* @see CRM_Utils_Hook::entityTypes()
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
*/
function eck_civicrm_entityTypes(array &$entityTypes): void {
$eck_entity_types = CRM_Core_DAO::executeQuery(
'SELECT * FROM `civicrm_eck_entity_type`;'
)->fetchAll('id');
foreach ($eck_entity_types as $entity_type) {
// "CRM_Eck_DAO_*" is a virtual class name, the corresponding class does
// not exist. "CRM_Eck_DAO_Entity" is therefore defined as the controller
// class.
$entityTypes['CRM_Eck_DAO_' . $entity_type['name']] = [
'name' => 'Eck_' . $entity_type['name'],
'class' => 'CRM_Eck_DAO_Entity',
'table' => _eck_get_table_name($entity_type['name']),
];
}
}
/**
* Convert ECK EntityType name to sql table name.
*
* @param string $entityTypeName
* @return string
*/
function _eck_get_table_name(string $entityTypeName): string {
// SQL table names must be alphanumeric and no longer than 64 characters
return CRM_Utils_String::munge('civicrm_eck_' . strtolower($entityTypeName), '_', 64);
}