7
7
namespace Drupal \content_entity_example \Entity ;
8
8
9
9
use Drupal \Core \Entity \EntityStorageInterface ;
10
- use Drupal \Core \Field \FieldDefinition ;
10
+ use Drupal \Core \Field \BaseFieldDefinition ;
11
11
use Drupal \Core \Entity \ContentEntityBase ;
12
12
use Drupal \Core \Entity \EntityTypeInterface ;
13
13
use Drupal \content_entity_example \ContactInterface ;
14
14
use Drupal \user \UserInterface ;
15
+
15
16
/**
16
17
* Defines the ContentEntityExample entity.
17
18
*
@@ -186,13 +187,13 @@ public function setOwner(UserInterface $account) {
186
187
public static function baseFieldDefinitions (EntityTypeInterface $ entity_type ) {
187
188
188
189
// Standard field, used as unique if primary index.
189
- $ fields ['id ' ] = FieldDefinition ::create ('integer ' )
190
+ $ fields ['id ' ] = BaseFieldDefinition ::create ('integer ' )
190
191
->setLabel (t ('ID ' ))
191
192
->setDescription (t ('The ID of the Contact entity. ' ))
192
193
->setReadOnly (TRUE );
193
194
194
195
// Standard field, unique outside of the scope of the current project.
195
- $ fields ['uuid ' ] = FieldDefinition ::create ('uuid ' )
196
+ $ fields ['uuid ' ] = BaseFieldDefinition ::create ('uuid ' )
196
197
->setLabel (t ('UUID ' ))
197
198
->setDescription (t ('The UUID of the Contact entity. ' ))
198
199
->setReadOnly (TRUE );
@@ -201,7 +202,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
201
202
// We set display options for the view as well as the form.
202
203
// Users with correct privileges can change the view and edit configuration.
203
204
204
- $ fields ['name ' ] = FieldDefinition ::create ('string ' )
205
+ $ fields ['name ' ] = BaseFieldDefinition ::create ('string ' )
205
206
->setLabel (t ('Name ' ))
206
207
->setDescription (t ('The name of the Contact entity. ' ))
207
208
->setSettings (array (
@@ -221,7 +222,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
221
222
->setDisplayConfigurable ('form ' , TRUE )
222
223
->setDisplayConfigurable ('view ' , TRUE );
223
224
224
- $ fields ['first_name ' ] = FieldDefinition ::create ('string ' )
225
+ $ fields ['first_name ' ] = BaseFieldDefinition ::create ('string ' )
225
226
->setLabel (t ('First Name ' ))
226
227
->setDescription (t ('The first name of the Contact entity. ' ))
227
228
->setSettings (array (
@@ -246,7 +247,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
246
247
// The values shown in the menu are 'male' and 'female'.
247
248
// In the view the field content is shown as string.
248
249
// In the form the choices are presented as options list.
249
- $ fields ['gender ' ] = FieldDefinition ::create ('list_text ' )
250
+ $ fields ['gender ' ] = BaseFieldDefinition ::create ('list_text ' )
250
251
->setLabel (t ('Gender ' ))
251
252
->setDescription (t ('The gender of the Contact entity. ' ))
252
253
->setSettings (array (
@@ -271,7 +272,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
271
272
// Entity reference field, holds the reference to the user object.
272
273
// The view shows the user name field of the user.
273
274
// 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 ' )
275
276
->setLabel (t ('User Name ' ))
276
277
->setDescription (t ('The Name of the associated user. ' ))
277
278
->setSetting ('target_type ' , 'user ' )
@@ -294,14 +295,14 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
294
295
->setDisplayConfigurable ('form ' , TRUE )
295
296
->setDisplayConfigurable ('view ' , TRUE );
296
297
297
- $ fields ['langcode ' ] = FieldDefinition ::create ('language ' )
298
+ $ fields ['langcode ' ] = BaseFieldDefinition ::create ('language ' )
298
299
->setLabel (t ('Language code ' ))
299
300
->setDescription (t ('The language code of ContentEntityExample entity. ' ));
300
- $ fields ['created ' ] = FieldDefinition ::create ('created ' )
301
+ $ fields ['created ' ] = BaseFieldDefinition ::create ('created ' )
301
302
->setLabel (t ('Created ' ))
302
303
->setDescription (t ('The time that the entity was created. ' ));
303
304
304
- $ fields ['changed ' ] = FieldDefinition ::create ('changed ' )
305
+ $ fields ['changed ' ] = BaseFieldDefinition ::create ('changed ' )
305
306
->setLabel (t ('Changed ' ))
306
307
->setDescription (t ('The time that the entity was last edited. ' ));
307
308
0 commit comments