Scroll
Content Entity
This cheat sheet provides an overview of commonly used methods, classes, and interfaces for content entities.
![]()
/sites/default/files/drupal-content-entity-8.0.pdf
Content entities inherit much of their behavior from entities. See Working with the Entity API for those shared features.
Managing Field Values
Create custom fields using the baseFieldDefinitions method for your content entity.
- Load an instance of your custom entity into a local variable
$Custom_Entity - Define a custom field named
custom_field - Store some data
Code Example
$custom_field_value = $Custom_Entity->custom_field->value;
// Perform some kind of data manipulation
$Custom_Entity->custom_field->value = $custom_field_value;
$Custom_Entity->save();
Examples of content entities:
- node
- comment
- user