1 entity_example.inc public EntityExampleBasicController::create()

Create and return a new entity_example_basic entity.

Overrides EntityExampleBasicControllerInterface::create

File

modules/examples/entity_example/entity_example.inc, line 120

Class

EntityExampleBasicController
EntityExampleBasicController extends BackdropDefaultEntityController.

Code

public function create() {
  // It is important when creating entities in Backdrop to ensure that you
  // create an instance of the core Entity class rather than an instance of 
  // stdClass(). This would lead to exceptions on attempting to save your
  // custom entity.
  // See https://github.com/backdrop/backdrop-issues/issues/2558
  $entity = new EntityExampleBasic();
  $entity->type = 'entity_example_basic';
  $entity->basic_id = 0;
  $entity->bundle_type = 'first_example_bundle';
  $entity->item_description = '';
  return $entity;
}