Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.91% covered (success)
90.91%
10 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
UserContactStorageSchema
90.91% covered (success)
90.91%
10 / 11
0.00% covered (danger)
0.00%
0 / 1
3.01
0.00% covered (danger)
0.00%
0 / 1
 getEntitySchema
90.91% covered (success)
90.91%
10 / 11
0.00% covered (danger)
0.00%
0 / 1
3.01
1<?php
2
3namespace Drupal\crm;
4
5use Drupal\Core\Entity\ContentEntityTypeInterface;
6use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
7
8/**
9 * Defines the crm_user_contact schema handler.
10 */
11class UserContactStorageSchema extends SqlContentEntityStorageSchema {
12
13  /**
14   * {@inheritdoc}
15   */
16  protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
17    $schema = parent::getEntitySchema($entity_type, $reset);
18    $data_table = 'crm_user_contact';
19    if (isset($schema[$data_table])) {
20
21      if (!isset($schema[$data_table]['unique keys'])) {
22        $schema[$data_table]['unique keys'] = [];
23      }
24      $schema[$data_table]['unique keys'] += [
25        'crm_user_contact__user' => ['user'],
26        'crm_user_contact__crm_contact' => ['crm_contact'],
27      ];
28      $schema[$data_table]['fields']['user']['not null'] = TRUE;
29      $schema[$data_table]['fields']['crm_contact']['not null'] = TRUE;
30    }
31
32    return $schema;
33  }
34
35}