Example: Config Entity

Same name in other branches
  1. 3.x modules/config_entity_example/config_entity_example.module \config_entity_example
  2. 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/config_entity_example/tests/src/Functional/ConfigEntityExampleTest.php Test the Config Entity Example module.
Robot modules/config_entity_example/src/Entity/Robot.php Defines the robot entity.
RobotAccessController modules/config_entity_example/src/RobotAccessController.php Defines an access controller for the robot entity.
RobotAddForm modules/config_entity_example/src/Form/RobotAddForm.php Class RobotAddForm.
RobotDeleteForm modules/config_entity_example/src/Form/RobotDeleteForm.php Class RobotDeleteForm.
RobotEditForm modules/config_entity_example/src/Form/RobotEditForm.php Class RobotEditForm.
RobotFormBase modules/config_entity_example/src/Form/RobotFormBase.php Class RobotFormBase.
RobotListBuilder modules/config_entity_example/src/Controller/RobotListBuilder.php Provides a listing of robot entities.
RobotReferenceTest modules/config_entity_example/tests/src/Functional/RobotReferenceTest.php Ensure Robot entities can be used in entity_reference fields.