class Robot

Same name in other branches
  1. 3.x modules/config_entity_example/src/Entity/Robot.php \Drupal\config_entity_example\Entity\Robot
  2. 4.0.x modules/config_entity_example/src/Entity/Robot.php \Drupal\config_entity_example\Entity\Robot

Defines the robot entity.

The lines below, starting with '@ConfigEntityType,' are a plugin annotation. These define the entity type to the entity type manager.

The properties in the annotation are as follows:

  • id: The machine name of the entity type.
  • label: The human-readable label of the entity type. We pass this through the "@Translation" wrapper so that the multilingual system may translate it in the user interface.
  • handlers: An array of entity handler classes, keyed by handler type.
    • access: The class that is used for access checks.
    • list_builder: The class that provides listings of the entity.
    • form: An array of entity form classes keyed by their operation.
  • entity_keys: Specifies the class properties in which unique keys are stored for this entity type. Unique keys are properties which you know will be unique, and which the entity manager can use as unique in database queries.
  • links: entity URL definitions. These are mostly used for Field UI. Arbitrary keys can set here. For example, User sets cancel-form, while Node uses delete-form.

Plugin annotation


@ConfigEntityType(
  id = "robot",
  label = @Translation("Robot"),
  admin_permission = "administer robots",
  handlers = {
    "access" = "Drupal\config_entity_example\RobotAccessController",
    "list_builder" = "Drupal\config_entity_example\Controller\RobotListBuilder",
    "form" = {
      "add" = "Drupal\config_entity_example\Form\RobotAddForm",
      "edit" = "Drupal\config_entity_example\Form\RobotEditForm",
      "delete" = "Drupal\config_entity_example\Form\RobotDeleteForm"
    }
  },
  entity_keys = {
    "id" = "id",
    "label" = "label"
  },
  links = {
    "edit-form" = "/examples/config_entity_example/manage/{robot}",
    "delete-form" = "/examples/config_entity_example/manage/{robot}/delete"
  },
  config_export = {
    "id",
    "uuid",
    "label",
    "floopy"
  }
)

Hierarchy

  • class \Drupal\config_entity_example\Entity\Robot extends \Drupal\Core\Config\Entity\ConfigEntityBase

Expanded class hierarchy of Robot

See also

http://previousnext.com.au/blog/understanding-drupal-8s-config-entities

annotation

Drupal\Core\Annotation\Translation

Related topics

2 files declare their use of Robot
ConfigEntityExampleTest.php in config_entity_example/tests/src/Functional/ConfigEntityExampleTest.php
RobotReferenceTest.php in config_entity_example/tests/src/Functional/RobotReferenceTest.php
5 string references to 'Robot'
config_entity_example.routing.yml in config_entity_example/config_entity_example.routing.yml
config_entity_example/config_entity_example.routing.yml
config_entity_example.schema.yml in config_entity_example/config/schema/config_entity_example.schema.yml
config_entity_example/config/schema/config_entity_example.schema.yml
RobotFormBase::create in config_entity_example/src/Form/RobotFormBase.php
Factory method for RobotFormBase.
RobotListBuilder::buildHeader in config_entity_example/src/Controller/RobotListBuilder.php
Builds the header row for the entity listing.
RobotReferenceTest::testEntityReference in config_entity_example/tests/src/Functional/RobotReferenceTest.php
Ensure we can use robot entities as reference fields.

File

config_entity_example/src/Entity/Robot.php, line 65

Namespace

Drupal\config_entity_example\Entity
View source
class Robot extends ConfigEntityBase {
    
    /**
     * The robot ID.
     *
     * @var string
     */
    public $id;
    
    /**
     * The robot UUID.
     *
     * @var string
     */
    public $uuid;
    
    /**
     * The robot label.
     *
     * @var string
     */
    public $label;
    
    /**
     * The robot floopy flag.
     *
     * @var string
     */
    public $floopy;

}

Members

Title Sort descending Modifiers Object type Summary
Robot::$floopy public property The robot floopy flag.
Robot::$id public property The robot ID.
Robot::$label public property The robot label.
Robot::$uuid public property The robot UUID.