Annotations Type UI — Developer Reference
Developer-focused reference. For module overview, permissions, and config management see README.md.
Extending annotation types with custom behaviors
AnnotationType implements ThirdPartySettingsInterface, allowing modules to attach their own properties to an annotation type without modifying the core entity.
A module that wants to add a behavior to annotation types (e.g. "expose this type in the front-end AI bot") does three things:
1. Declare a schema for the settings:
# config/schema/mymodule.schema.yml
annotations.annotation_type.*.third_party.mymodule:
type: mapping
label: 'My module annotation type settings'
mapping:
in_frontend_bot:
type: boolean
label: 'Show in front-end bot'
2. Inject a form element via hook_form_annotation_type_form_alter:
function mymodule_form_annotation_type_form_alter(array &$form, FormStateInterface $form_state): void {
$type = $form_state->getFormObject()->getEntity();
$form['in_frontend_bot'] = [
'#type' => 'checkbox',
'#title' => t('Show in front-end bot'),
'#default_value' => $type->getThirdPartySetting('mymodule', 'in_frontend_bot', FALSE),
];
$form['#entity_builders'][] = 'mymodule_form_annotation_type_form_builder';
}
function mymodule_form_annotation_type_form_builder(string $entity_type, AnnotationType $type, array &$form, FormStateInterface $form_state): void {
$type->setThirdPartySetting('mymodule', 'in_frontend_bot', (bool) $form_state->getValue('in_frontend_bot'));
}
3. Read the setting wherever needed:
$show = $annotationType->getThirdPartySetting('mymodule', 'in_frontend_bot', FALSE);
The value is stored on the config entity alongside its first-party properties and exported with drush cex. From the editor's perspective the checkbox appears as part of the type edit form with no visible indication it comes from a different module.
This pattern is appropriate when the contributing module owns the full lifecycle of the behavior: it writes it, reads it, and acts on it. The annotations module's own services have no knowledge of third-party settings added by other modules.