function social_comment_edit_form_submit in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 8.3 modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 8.4 modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 8.5 modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 8.6 modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 8.7 modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 10.3.x modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 10.0.x modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 10.1.x modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
- 10.2.x modules/social_features/social_comment/social_comment.module \social_comment_edit_form_submit()
Generates a message when comment with children is getting unpublished.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state interface of the form.
1 string reference to 'social_comment_edit_form_submit'
- social_comment_form_comment_form_alter in modules/
social_features/ social_comment/ social_comment.module - Implements hook_form_FORM_ID_alter().
File
- modules/
social_features/ social_comment/ social_comment.module, line 97 - The Social comment module.
Code
function social_comment_edit_form_submit(array $form, FormStateInterface $form_state) {
if (isset($form['author']['status']['#default_value']) && $form['author']['status']['#default_value'] === '1') {
if ($form_state
->getValue('status') === 0) {
// Load the comment and verify if it has any children.
/** @var \Drupal\comment\CommentStorage $entity_storage */
$entity_storage = \Drupal::entityTypeManager()
->getStorage('comment');
$cid = $form_state
->getValue('cid');
$comment = $entity_storage
->load($cid);
$children = $entity_storage
->getChildCids([
$cid => $comment,
]);
if (!empty($children)) {
$messenger = \Drupal::messenger();
$messenger
->addMessage(t('All the replies placed on an unpublished comment will be hidden automatically.'), 'warning');
}
}
}
}