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