Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
12.50% covered (danger)
12.50%
1 / 8
14.29% covered (danger)
14.29%
1 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
ContactType
12.50% covered (danger)
12.50%
1 / 8
14.29% covered (danger)
14.29%
1 / 7
39.83
0.00% covered (danger)
0.00%
0 / 1
 id
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isLocked
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHelp
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDescription
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDescription
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 shouldCreateNewRevision
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNewRevision
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Drupal\crm\Entity;
4
5use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
6use Drupal\crm\CrmContactTypeInterface;
7
8/**
9 * Defines the Contact type configuration entity.
10 *
11 * @ConfigEntityType(
12 *   id = "crm_contact_type",
13 *   label = @Translation("Contact type"),
14 *   label_collection = @Translation("Contact types"),
15 *   label_singular = @Translation("contact type"),
16 *   label_plural = @Translation("contacts types"),
17 *   label_count = @PluralTranslation(
18 *     singular = "@count contacts type",
19 *     plural = "@count contacts types",
20 *   ),
21 *   handlers = {
22 *     "access" = "Drupal\crm\ContactTypeAccessControlHandler",
23 *     "form" = {
24 *       "add" = "Drupal\crm\Form\ContactTypeForm",
25 *       "edit" = "Drupal\crm\Form\ContactTypeForm",
26 *       "delete" = "Drupal\Core\Entity\EntityDeleteForm",
27 *     },
28 *     "list_builder" = "Drupal\crm\ContactTypeListBuilder",
29 *     "route_provider" = {
30 *       "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
31 *     }
32 *   },
33 *   admin_permission = "administer contact types",
34 *   bundle_of = "crm_contact",
35 *   config_prefix = "crm_contact_type",
36 *   entity_keys = {
37 *     "id" = "id",
38 *     "label" = "label",
39 *     "uuid" = "uuid"
40 *   },
41 *   links = {
42 *     "add-form" = "/admin/structure/crm/contact-types/add",
43 *     "edit-form" = "/admin/structure/crm/contact-types/manage/{crm_contact_type}",
44 *     "delete-form" = "/admin/structure/crm/contact-types/manage/{crm_contact_type}/delete",
45 *     "collection" = "/admin/structure/crm/contact-types"
46 *   },
47 *   config_export = {
48 *     "id",
49 *     "label",
50 *     "description",
51 *     "help",
52 *     "new_revision",
53 *     "uuid",
54 *     "primary",
55 *     "locked",
56 *   }
57 * )
58 */
59class ContactType extends ConfigEntityBundleBase implements CrmContactTypeInterface {
60
61  /**
62   * The machine name of this contact type.
63   *
64   * @var string
65   */
66  protected $id;
67
68  /**
69   * The human-readable name of the contact type.
70   *
71   * @var string
72   */
73  protected $label;
74
75  /**
76   * A description of the contact type.
77   *
78   * @var string|null
79   */
80  protected $description;
81
82  /**
83   * The primary relationship type.
84   *
85   * @var string
86   */
87  protected $primary;
88
89  /**
90   * Whether the contact type is locked.
91   *
92   * @var bool
93   */
94  protected $locked = FALSE;
95
96  /**
97   * Help text for the contact type.
98   *
99   * @var string
100   */
101  protected $help;
102
103  /**
104   * Whether a new revision should be created by default.
105   *
106   * @var bool
107   */
108  protected $new_revision = TRUE;
109
110  /**
111   * {@inheritdoc}
112   */
113  public function id() {
114    return $this->id;
115  }
116
117  /**
118   * Is the contact type locked?
119   */
120  public function isLocked() {
121    return $this->locked;
122  }
123
124  /**
125   * {@inheritdoc}
126   */
127  public function getHelp() {
128    return $this->help ?? '';
129  }
130
131  /**
132   * {@inheritdoc}
133   */
134  public function getDescription() {
135    return $this->description ?? '';
136  }
137
138  /**
139   * {@inheritdoc}
140   */
141  public function setDescription($description) {
142    $this->description = $description;
143
144    return $this;
145  }
146
147  /**
148   * {@inheritdoc}
149   */
150  public function shouldCreateNewRevision() {
151    return $this->new_revision;
152  }
153
154  /**
155   * {@inheritdoc}
156   */
157  public function setNewRevision($new_revision) {
158    $this->new_revision = $new_revision;
159  }
160
161}