Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ContactDetailType
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 isLocked
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
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\crm\Entity;
6
7use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
8use Drupal\Core\Entity\Attribute\ConfigEntityType;
9use Drupal\Core\Entity\EntityDeleteForm;
10use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
11use Drupal\Core\StringTranslation\TranslatableMarkup;
12use Drupal\crm\CrmContactDetailTypeInterface;
13use Drupal\crm\ContactDetailTypeAccessControlHandler;
14use Drupal\crm\ContactDetailTypeListBuilder;
15use Drupal\crm\Form\ContactDetailTypeForm;
16
17/**
18 * Defines the CRM Contact Detail type configuration entity.
19 */
20#[ConfigEntityType(
21  id: 'crm_contact_detail_type',
22  label: new TranslatableMarkup('CRM Contact Detail type'),
23  label_collection: new TranslatableMarkup('CRM Contact Detail types'),
24  label_singular: new TranslatableMarkup('crm contact detail type'),
25  label_plural: new TranslatableMarkup('crm contact details types'),
26  label_count: [
27    'singular' => '@count crm contact details type',
28    'plural' => '@count crm contact details types',
29  ],
30  handlers: [
31    'access' => ContactDetailTypeAccessControlHandler::class,
32    'form' => [
33      'add' => ContactDetailTypeForm::class,
34      'edit' => ContactDetailTypeForm::class,
35      'delete' => EntityDeleteForm::class,
36    ],
37    'list_builder' => ContactDetailTypeListBuilder::class,
38    'route_provider' => [
39      'html' => AdminHtmlRouteProvider::class,
40    ],
41  ],
42  admin_permission: 'administer crm',
43  bundle_of: 'crm_contact_detail',
44  config_prefix: 'crm_contact_detail_type',
45  entity_keys: [
46    'id' => 'id',
47    'label' => 'label',
48    'uuid' => 'uuid',
49  ],
50  links: [
51    'add-form' => '/admin/structure/crm/contact-detail-types/add',
52    'edit-form' => '/admin/structure/crm/contact-detail-types/manage/{crm_contact_detail_type}',
53    'delete-form' => '/admin/structure/crm/contact-detail-types/manage/{crm_contact_detail_type}/delete',
54    'collection' => '/admin/structure/crm/contact-detail-types',
55  ],
56  config_export: [
57    'id',
58    'label',
59    'description',
60    'uuid',
61    'locked',
62  ],
63)]
64final class ContactDetailType extends ConfigEntityBundleBase implements CrmContactDetailTypeInterface {
65
66  /**
67   * The machine name of this crm contact detail type.
68   */
69  protected string $id;
70
71  /**
72   * The human-readable name of the crm contact detail type.
73   */
74  protected string $label;
75
76  /**
77   * The description of the crm contact detail type.
78   *
79   * @var string|null
80   */
81  protected ?string $description;
82
83  /**
84   * Whether the Contact Detail Type is locked.
85   */
86  protected bool $locked = FALSE;
87
88  /**
89   * Is the contact type locked?
90   */
91  public function isLocked(): bool {
92    return $this->locked;
93  }
94
95  /**
96   * {@inheritdoc}
97   */
98  public function getDescription() {
99    return $this->description ?? '';
100  }
101
102  /**
103   * {@inheritdoc}
104   */
105  public function setDescription($description) {
106    $this->description = $description;
107
108    return $this;
109  }
110
111}