-
Notifications
You must be signed in to change notification settings - Fork 3
/
civiremote.module
54 lines (48 loc) · 1.41 KB
/
civiremote.module
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
<?php
use Drupal\civiremote;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\user\UserInterface;
/**
* Implements hook_entity_insert().
*/
function civiremote_entity_insert(EntityInterface $entity) {
if ($entity->getEntityTypeId() == 'user') {
/* @var UserInterface $entity */
civiremote\User::create($entity);
}
}
/**
* Implements hook_user_login().
*/
function civiremote_user_login(UserInterface $account) {
civiremote\User::login($account);
}
/**
* Implements hook_entity_base_field_info().
*/
function civiremote_entity_base_field_info(EntityTypeInterface $entity_type) {
// Add a base field to the User entity for storing the CiviRFemote ID.
$fields = [];
if ($entity_type->id() === 'user') {
$fields['civiremote_id'] = BaseFieldDefinition::create('string')
->setLabel(t('CiviRemote ID'))
->setDescription(t('The unique CiviRemote ID for the user in the connected CiviCRM.'))
->setDisplayOptions('view', [
'label' => 'visible',
'type' => 'string',
'weight' => -5,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'settings' => [
'display_label' => TRUE,
],
])
->setDisplayConfigurable('form', TRUE)
->setRequired(FALSE);
}
return $fields;
}