You are here

function _social_group_type_edit_submit in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  2. 8.5 modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  3. 8.6 modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  4. 8.7 modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  5. 8.8 modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  6. 10.3.x modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  7. 10.0.x modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  8. 10.1.x modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()
  9. 10.2.x modules/social_features/social_group/social_group.module \_social_group_type_edit_submit()

Form submit for removing members from a group so we can clear caches.

Throws

\Drupal\Core\Entity\EntityStorageException

1 string reference to '_social_group_type_edit_submit'
social_group_form_alter in modules/social_features/social_group/social_group.module
Implements hook_form_alter().

File

modules/social_features/social_group/social_group.module, line 545
The Social group module.

Code

function _social_group_type_edit_submit($form, FormStateInterface $form_state) {

  // Check if the group_type changed.
  $default_type = $form['group_type']['#default_value'];
  $new_type = $form_state
    ->getValue('group_type');

  // Update the Group entity and all it's content when the type changed.
  if ($new_type !== $default_type) {
    $group = _social_group_get_current_group();

    // Update the default visibility of all the content.
    GroupContentVisibilityUpdate::batchUpdateGroupContentVisibility($group, $new_type);

    // Make sure we clear cache tags accordingly.
    $cache_tags = _social_group_cache_tags($group);
    foreach ($cache_tags as $cache_tag) {
      Cache::invalidateTags([
        $cache_tag,
      ]);
    }
  }
}