Example: Config Entity
Same name in other branches
- 3.x modules/config_entity_example/config_entity_example.module \config_entity_example
- 8.x-1.x config_entity_example/config_entity_example.module \config_entity_example
Implement a Config Entity.
This module demonstrates implementing a Config Entity.
This is an example of a simple configuration entity, the kind you might create to store administrator-defined objects like blocks or views.
In this module we define a configuration entity named 'Robot'. The entity has a unique ID (also called a machine name), a human-readable label used for display, and a universally unique identifier. You can create new robots by navigating to <your_site_root>/examples/config_entity_example. A default robot, "marvin", is included with the module.
What's special about a Configuration Entity?
Configuration entities are entities just like content entities. The key difference is where the data is stored. Content entities are stored in the database. Configuration entities are stored in *.yml files, typically under <your_site_root>/sites/default/files/config_<unique_id>.
Another key difference with configuration entities is the expectation they are created by administrators, and not end users. As files, configuration entities can be added to a version control system.
Originally based on code from blog post at http://previousnext.com.au/blog/understanding-drupal-8s-config-entities
Parent topics
File
-
modules/
config_entity_example/ config_entity_example.module, line 8
Classes
Title Sort descending | File name | Summary |
---|---|---|
ConfigEntityExampleTest | modules/ |
Test the Config Entity Example module. |
Robot | modules/ |
Defines the robot entity. |
RobotAccessController | modules/ |
Defines an access controller for the robot entity. |
RobotAddForm | modules/ |
Class RobotAddForm. |
RobotDeleteForm | modules/ |
Class RobotDeleteForm. |
RobotEditForm | modules/ |
Class RobotEditForm. |
RobotFormBase | modules/ |
Class RobotFormBase. |
RobotListBuilder | modules/ |
Provides a listing of robot entities. |
RobotReferenceTest | modules/ |
Ensure Robot entities can be used in entity_reference fields. |