comparison core/modules/block_content/src/Entity/BlockContent.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php 1 <?php
2 2
3 namespace Drupal\block_content\Entity; 3 namespace Drupal\block_content\Entity;
4 4
5 use Drupal\Core\Entity\ContentEntityBase; 5 use Drupal\Core\Entity\EditorialContentEntityBase;
6 use Drupal\Core\Entity\EntityChangedTrait;
7 use Drupal\Core\Entity\EntityStorageInterface; 6 use Drupal\Core\Entity\EntityStorageInterface;
8 use Drupal\Core\Entity\EntityTypeInterface; 7 use Drupal\Core\Entity\EntityTypeInterface;
9 use Drupal\Core\Field\BaseFieldDefinition; 8 use Drupal\Core\Field\BaseFieldDefinition;
10 use Drupal\block_content\BlockContentInterface; 9 use Drupal\block_content\BlockContentInterface;
11 use Drupal\user\UserInterface; 10 use Drupal\user\UserInterface;
49 * "id" = "id", 48 * "id" = "id",
50 * "revision" = "revision_id", 49 * "revision" = "revision_id",
51 * "bundle" = "type", 50 * "bundle" = "type",
52 * "label" = "info", 51 * "label" = "info",
53 * "langcode" = "langcode", 52 * "langcode" = "langcode",
54 * "uuid" = "uuid" 53 * "uuid" = "uuid",
54 * "published" = "status",
55 * }, 55 * },
56 * revision_metadata_keys = { 56 * revision_metadata_keys = {
57 * "revision_user" = "revision_user", 57 * "revision_user" = "revision_user",
58 * "revision_created" = "revision_created", 58 * "revision_created" = "revision_created",
59 * "revision_log_message" = "revision_log" 59 * "revision_log_message" = "revision_log"
66 * Note that render caching of block_content entities is disabled because they 66 * Note that render caching of block_content entities is disabled because they
67 * are always rendered as blocks, and blocks already have their own render 67 * are always rendered as blocks, and blocks already have their own render
68 * caching. 68 * caching.
69 * See https://www.drupal.org/node/2284917#comment-9132521 for more information. 69 * See https://www.drupal.org/node/2284917#comment-9132521 for more information.
70 */ 70 */
71 class BlockContent extends ContentEntityBase implements BlockContentInterface { 71 class BlockContent extends EditorialContentEntityBase implements BlockContentInterface {
72
73 use EntityChangedTrait;
74 72
75 /** 73 /**
76 * The theme the block is being created in. 74 * The theme the block is being created in.
77 * 75 *
78 * When creating a new custom block from the block library, the user is 76 * When creating a new custom block from the block library, the user is
171 169
172 $fields['langcode']->setDescription(t('The custom block language code.')); 170 $fields['langcode']->setDescription(t('The custom block language code.'));
173 171
174 $fields['type']->setLabel(t('Block type')) 172 $fields['type']->setLabel(t('Block type'))
175 ->setDescription(t('The block type.')); 173 ->setDescription(t('The block type.'));
174
175 $fields['revision_log']->setDescription(t('The log entry explaining the changes in this revision.'));
176 176
177 $fields['info'] = BaseFieldDefinition::create('string') 177 $fields['info'] = BaseFieldDefinition::create('string')
178 ->setLabel(t('Block description')) 178 ->setLabel(t('Block description'))
179 ->setDescription(t('A brief description of your block.')) 179 ->setDescription(t('A brief description of your block.'))
180 ->setRevisionable(TRUE) 180 ->setRevisionable(TRUE)
185 'weight' => -5, 185 'weight' => -5,
186 ]) 186 ])
187 ->setDisplayConfigurable('form', TRUE) 187 ->setDisplayConfigurable('form', TRUE)
188 ->addConstraint('UniqueField', []); 188 ->addConstraint('UniqueField', []);
189 189
190 $fields['revision_log'] = BaseFieldDefinition::create('string_long')
191 ->setLabel(t('Revision log message'))
192 ->setDescription(t('The log entry explaining the changes in this revision.'))
193 ->setRevisionable(TRUE)
194 ->setDisplayOptions('form', [
195 'type' => 'string_textarea',
196 'weight' => 25,
197 'settings' => [
198 'rows' => 4,
199 ],
200 ]);
201
202 $fields['changed'] = BaseFieldDefinition::create('changed') 190 $fields['changed'] = BaseFieldDefinition::create('changed')
203 ->setLabel(t('Changed')) 191 ->setLabel(t('Changed'))
204 ->setDescription(t('The time that the custom block was last edited.')) 192 ->setDescription(t('The time that the custom block was last edited.'))
205 ->setTranslatable(TRUE) 193 ->setTranslatable(TRUE)
206 ->setRevisionable(TRUE); 194 ->setRevisionable(TRUE);
207 195
208 $fields['revision_created'] = BaseFieldDefinition::create('created')
209 ->setLabel(t('Revision create time'))
210 ->setDescription(t('The time that the current revision was created.'))
211 ->setRevisionable(TRUE);
212
213 $fields['revision_user'] = BaseFieldDefinition::create('entity_reference')
214 ->setLabel(t('Revision user'))
215 ->setDescription(t('The user ID of the author of the current revision.'))
216 ->setSetting('target_type', 'user')
217 ->setRevisionable(TRUE);
218
219 return $fields; 196 return $fields;
220 } 197 }
221 198
222 /** 199 /**
223 * {@inheritdoc} 200 * {@inheritdoc}