|
6 | 6 |
|
7 | 7 | use Drupal\Core\Entity\ContentEntityBase; |
8 | 8 | use Drupal\Core\Entity\EntityChangedTrait; |
| 9 | +use Drupal\Core\Entity\EntityPublishedInterface; |
| 10 | +use Drupal\Core\Entity\EntityPublishedTrait; |
9 | 11 | use Drupal\Core\Entity\EntityTypeInterface; |
10 | 12 | use Drupal\Core\Field\BaseFieldDefinition; |
11 | 13 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
|
47 | 49 | * "bundle" = "collection", |
48 | 50 | * "label" = "title", |
49 | 51 | * "uuid" = "uuid", |
| 52 | + * "published" = "status", |
50 | 53 | * }, |
51 | 54 | * links = { |
52 | 55 | * "collection" = "/admin/content/pantheon-content-publisher", |
|
59 | 62 | class PantheonDocument extends ContentEntityBase implements PantheonDocumentInterface { |
60 | 63 |
|
61 | 64 | use EntityChangedTrait; |
| 65 | + use EntityPublishedTrait; |
62 | 66 |
|
63 | 67 | /** |
64 | 68 | * {@inheritdoc} |
65 | 69 | */ |
66 | 70 | public static function baseFieldDefinitions(EntityTypeInterface $entity_type): array { |
67 | 71 |
|
68 | 72 | $fields = parent::baseFieldDefinitions($entity_type); |
| 73 | + $fields += static::publishedBaseFieldDefinitions($entity_type); |
69 | 74 | // In order to work around the InnoDB 191 character limit on utf8mb4 |
70 | 75 | // primary keys, we set the character set for the field to ASCII. |
71 | 76 | $fields['id'] = BaseFieldDefinition::create('string') |
@@ -110,10 +115,9 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type): a |
110 | 115 | ]) |
111 | 116 | ->setDisplayConfigurable('view', TRUE); |
112 | 117 |
|
113 | | - $fields['status'] = BaseFieldDefinition::create('boolean') |
114 | | - ->setLabel(t('Status')) |
115 | | - ->setDefaultValue(TRUE) |
116 | | - ->setSetting('on_label', 'Enabled') |
| 118 | + $fields['status'] |
| 119 | + ->setDescription(t('A boolean value indicating whether the document is published. Controlled externally by Content Publisher.')) |
| 120 | + ->setDisplayConfigurable('form', FALSE) |
117 | 121 | ->setDisplayOptions('view', [ |
118 | 122 | 'region' => 'hidden', |
119 | 123 | ]) |
|
0 commit comments