function CommentHooks::fieldStorageConfigInsert
Same name and namespace in other branches
- 11.x core/modules/comment/src/Hook/CommentHooks.php \Drupal\comment\Hook\CommentHooks::fieldStorageConfigInsert()
Implements hook_ENTITY_TYPE_insert() for 'field_storage_config'.
Attributes
#[Hook('field_storage_config_insert')]
File
-
core/
modules/ comment/ src/ Hook/ CommentHooks.php, line 135
Class
- CommentHooks
- Hook implementations for comment.
Namespace
Drupal\comment\HookCode
public function fieldStorageConfigInsert(FieldStorageConfigInterface $field_storage) : void {
if ($field_storage->getType() == 'comment') {
// Check that the target entity type uses an integer ID.
$entity_type = \Drupal::entityTypeManager()->getDefinition($field_storage->getTargetEntityTypeId());
if (!$entity_type->hasIntegerId()) {
throw new \UnexpectedValueException('You cannot attach a comment field to an entity with a non-integer ID field');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.