Skip to content

Commit 14abc3c

Browse files
committed
Branch blocker: FieldDefinition is now Drupal\Core\Field\BaseFieldDefinition
1 parent 879d86e commit 14abc3c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

content_entity_example/src/Entity/Contact.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
namespace Drupal\content_entity_example\Entity;
88

99
use Drupal\Core\Entity\EntityStorageInterface;
10-
use Drupal\Core\Field\FieldDefinition;
10+
use Drupal\Core\Field\BaseFieldDefinition;
1111
use Drupal\Core\Entity\ContentEntityBase;
1212
use Drupal\Core\Entity\EntityTypeInterface;
1313
use Drupal\content_entity_example\ContactInterface;
1414
use Drupal\user\UserInterface;
15+
1516
/**
1617
* Defines the ContentEntityExample entity.
1718
*
@@ -186,13 +187,13 @@ public function setOwner(UserInterface $account) {
186187
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
187188

188189
// Standard field, used as unique if primary index.
189-
$fields['id'] = FieldDefinition::create('integer')
190+
$fields['id'] = BaseFieldDefinition::create('integer')
190191
->setLabel(t('ID'))
191192
->setDescription(t('The ID of the Contact entity.'))
192193
->setReadOnly(TRUE);
193194

194195
// Standard field, unique outside of the scope of the current project.
195-
$fields['uuid'] = FieldDefinition::create('uuid')
196+
$fields['uuid'] = BaseFieldDefinition::create('uuid')
196197
->setLabel(t('UUID'))
197198
->setDescription(t('The UUID of the Contact entity.'))
198199
->setReadOnly(TRUE);
@@ -201,7 +202,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
201202
// We set display options for the view as well as the form.
202203
// Users with correct privileges can change the view and edit configuration.
203204

204-
$fields['name'] = FieldDefinition::create('string')
205+
$fields['name'] = BaseFieldDefinition::create('string')
205206
->setLabel(t('Name'))
206207
->setDescription(t('The name of the Contact entity.'))
207208
->setSettings(array(
@@ -221,7 +222,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
221222
->setDisplayConfigurable('form', TRUE)
222223
->setDisplayConfigurable('view', TRUE);
223224

224-
$fields['first_name'] = FieldDefinition::create('string')
225+
$fields['first_name'] = BaseFieldDefinition::create('string')
225226
->setLabel(t('First Name'))
226227
->setDescription(t('The first name of the Contact entity.'))
227228
->setSettings(array(
@@ -246,7 +247,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
246247
// The values shown in the menu are 'male' and 'female'.
247248
// In the view the field content is shown as string.
248249
// In the form the choices are presented as options list.
249-
$fields['gender'] = FieldDefinition::create('list_text')
250+
$fields['gender'] = BaseFieldDefinition::create('list_text')
250251
->setLabel(t('Gender'))
251252
->setDescription(t('The gender of the Contact entity.'))
252253
->setSettings(array(
@@ -271,7 +272,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
271272
// Entity reference field, holds the reference to the user object.
272273
// The view shows the user name field of the user.
273274
// The form presents a auto complete field for the user name.
274-
$fields['user_id'] = FieldDefinition::create('entity_reference')
275+
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
275276
->setLabel(t('User Name'))
276277
->setDescription(t('The Name of the associated user.'))
277278
->setSetting('target_type', 'user')
@@ -294,14 +295,14 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
294295
->setDisplayConfigurable('form', TRUE)
295296
->setDisplayConfigurable('view', TRUE);
296297

297-
$fields['langcode'] = FieldDefinition::create('language')
298+
$fields['langcode'] = BaseFieldDefinition::create('language')
298299
->setLabel(t('Language code'))
299300
->setDescription(t('The language code of ContentEntityExample entity.'));
300-
$fields['created'] = FieldDefinition::create('created')
301+
$fields['created'] = BaseFieldDefinition::create('created')
301302
->setLabel(t('Created'))
302303
->setDescription(t('The time that the entity was created.'));
303304

304-
$fields['changed'] = FieldDefinition::create('changed')
305+
$fields['changed'] = BaseFieldDefinition::create('changed')
305306
->setLabel(t('Changed'))
306307
->setDescription(t('The time that the entity was last edited.'));
307308

0 commit comments

Comments
 (0)