Score:1

How do I control config names?

bn flag

When creating a config entity, we get an example_entity.schema.yml file:

example_module.example_entity.*:
  type: config_entity
  label: 'Example config'
  mapping:
    id:
      type: string
      label: 'ID'
    label:
      type: label
      label: 'Label'
    uuid:
      type: string

Creating entities of this type will result in config names, where the asterisk is replaced with the "id" property of the entity:

example_module.example_entity.name_1
example_module.example_entity.name_2
...

But how to control, which property is used and how to add support for more properties? For example, in core's core.entity_form_display.*.*.*, what is mapping the entity type to first wildcard, the entity bundle to second and the display mode to third?

Score:1
cn flag

The remainder of the config name is by definition the ID:

core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php

 * Configuration object names of configuration entities are comprised of two
 * parts, separated by a dot:
 * - config_prefix: A string denoting the owner (module/extension) of the
 *   configuration object, followed by arbitrary other namespace identifiers
 *   that are declared by the owning extension; e.g., 'node.type'. The
 *   config_prefix does NOT contain a trailing dot. It is defined by the entity
 *   type's annotation.
 * - ID: A string denoting the entity ID within the entity type namespace; e.g.,
 *   'article'. Entity IDs may contain dots/periods. The entire remaining string
 *   after the config_prefix in a config name forms the entity ID. Additional or
 *   custom suffixes are not possible.

However, it is possible for the config entity class to override id() with a computed compound ID. Like in the example you've mentioned:

core/lib/Drupal/Core/Entity/EntityDisplayBase.php

  public function id() {
    return $this->targetEntityType . '.' . $this->bundle . '.' . $this->mode;
  }
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.