function comment_field_config_delete
comment_field_config_delete(FieldConfigInterface $field)
Implements hook_ENTITY_TYPE_delete() for 'field_config'.
File
- core/modules/comment/comment.module, line 183
- Enables users to comment on published content.
Code
function comment_field_config_delete(FieldConfigInterface $field) { if ($field->getType() == 'comment') { // Delete all comments that used by the entity bundle. $entity_query = \Drupal::entityQuery('comment'); $entity_query->condition('entity_type', $field->getEntityTypeId()); $entity_query->condition('field_name', $field->getName()); $cids = $entity_query->execute(); entity_delete_multiple('comment', $cids); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!comment!comment.module/function/comment_field_config_delete/8.1.x