Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| NameFormat | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| uri | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| isLocked | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\name\Entity; |
| 6 | |
| 7 | use Drupal\Core\Config\Entity\ConfigEntityBase; |
| 8 | |
| 9 | /** |
| 10 | * Defines the Name Format configuration entity class. |
| 11 | * |
| 12 | * @ConfigEntityType( |
| 13 | * id = "name_format", |
| 14 | * label = @Translation("Name format"), |
| 15 | * handlers = { |
| 16 | * "access" = "Drupal\name\Access\NameFormatAccessHandler", |
| 17 | * "list_builder" = "Drupal\name\ListBuilder\NameFormatListBuilder", |
| 18 | * "form" = { |
| 19 | * "add" = "Drupal\name\Form\NameFormatForm", |
| 20 | * "edit" = "Drupal\name\Form\NameFormatForm", |
| 21 | * "delete" = "Drupal\name\Form\NameFormatDeleteConfirm" |
| 22 | * }, |
| 23 | * "list_builder" = "Drupal\name\ListBuilder\NameFormatListBuilder" |
| 24 | * }, |
| 25 | * config_prefix = "name_format", |
| 26 | * fieldable = FALSE, |
| 27 | * entity_keys = { |
| 28 | * "id" = "id", |
| 29 | * "label" = "label", |
| 30 | * "uuid" = "uuid" |
| 31 | * }, |
| 32 | * config_export = { |
| 33 | * "id", |
| 34 | * "uuid", |
| 35 | * "label", |
| 36 | * "status", |
| 37 | * "langcode", |
| 38 | * "locked", |
| 39 | * "pattern", |
| 40 | * }, |
| 41 | * links = { |
| 42 | * "edit-form" = "/admin/config/regional/name/manage/{name_format}", |
| 43 | * "delete-form" = "/admin/config/regional/name/manage/{name_format}/delete" |
| 44 | * } |
| 45 | * ) |
| 46 | */ |
| 47 | class NameFormat extends ConfigEntityBase implements NameFormatInterface { |
| 48 | |
| 49 | /** |
| 50 | * The name format machine name. |
| 51 | * |
| 52 | * @var string |
| 53 | */ |
| 54 | public $id; |
| 55 | |
| 56 | /** |
| 57 | * The name format UUID. |
| 58 | * |
| 59 | * @var string |
| 60 | */ |
| 61 | public $uuid; |
| 62 | |
| 63 | /** |
| 64 | * The human-readable name of the name format entity. |
| 65 | * |
| 66 | * @var string |
| 67 | */ |
| 68 | public $label; |
| 69 | |
| 70 | /** |
| 71 | * The name format pattern. |
| 72 | * |
| 73 | * @var string |
| 74 | */ |
| 75 | public $pattern; |
| 76 | |
| 77 | /** |
| 78 | * The locked status of this name format. |
| 79 | * |
| 80 | * @var bool |
| 81 | */ |
| 82 | public $locked = FALSE; |
| 83 | |
| 84 | /** |
| 85 | * {@inheritdoc} |
| 86 | */ |
| 87 | public function uri() { |
| 88 | return [ |
| 89 | 'path' => 'admin/config/regional/name/manage/' . $this->id(), |
| 90 | 'options' => [ |
| 91 | 'entity_type' => $this->getEntityType(), |
| 92 | 'entity' => $this, |
| 93 | ], |
| 94 | ]; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * {@inheritdoc} |
| 99 | */ |
| 100 | public function isLocked() { |
| 101 | return (bool) $this->locked; |
| 102 | } |
| 103 | |
| 104 | } |