Content Entity

Last updated on
13 October 2016

This cheat sheet provides an overview of frequently used methods, classes and interfaces for content entities.

Download

Content entities inherit many of their behavior from Entities. See Working with the Entity API for these generic functions.

Manipulating field values

Create custom fields using the baseFieldDefinitions method for your Content entity.

  1. Read custom entity instance to local variable $Custom_Entity
  2. Define custom field called "custom_field"
  3. Store some data

 

Example code

$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();

 

Content entities examples

  • node
  • comment
  • user