Example: Content Entity in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/content_entity_example/content_entity_example.module \content_entity_example
Implement a content entity.
This module demonstrates implementing a content entity.
Entity API is the API that stores pieces of content and configuration for Drupal core. For instance, if you've encountered node content types, you've encountered entities of type 'node.'
This example implements the Entity API so that we have an entity type usable by the user which you might think of as specialized nodes, but which are different from nodes. These entities are called Contact, and are known internally by the machine name content_entity_example_contact.
Contact is a fieldable content entity used to hold structured information without the overhead of using a node content type. 'Fieldable' means you can attach fields to it, like you can with nodes. It is defined programmatically (completely in code). We will show the main techniques to handle and expose the contents of this entity type.
The Contact entity will demonstrate the main tasks for an entity:
- define
- save
- load
- view
- edit
- delete
- control access
Where ever possible, we use the amazing tools built into D8 natively.
}
See also
Drupal\content_entity_example\Entity\Contact
Parent topics
File
- content_entity_example/
content_entity_example.module, line 8 - Contains Drupal\content_entity_example\content_entity_example.module.
Classes
Name | Location | Description |
---|---|---|
Contact |
content_entity_example/ |
Defines the ContentEntityExample entity. |
ContactDeleteForm |
content_entity_example/ |
Provides a form for deleting a content_entity_example entity. |
ContactForm |
content_entity_example/ |
Form controller for the content_entity_example entity edit forms. |
ContactListBuilder |
content_entity_example/ |
Provides a list controller for content_entity_example entity. |
ContactSettingsForm |
content_entity_example/ |
Class ContentEntityExampleSettingsForm. |
ContactTest |
content_entity_example/ |
Test basic CRUD operations for our Contact entity type. |
ContentEntityExampleTest |
content_entity_example/ |
Tests the basic functions of the Content Entity Example module. |
Interfaces
Name | Location | Description |
---|---|---|
ContactInterface |
content_entity_example/ |
Provides an interface defining a Contact entity. |