You are here

public static function FlexibleGroupContentVisibilityUpdate::calculateVisibility in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::calculateVisibility()
  2. 8.7 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::calculateVisibility()
  3. 8.8 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::calculateVisibility()
  4. 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::calculateVisibility()
  5. 10.0.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::calculateVisibility()
  6. 10.1.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::calculateVisibility()
  7. 10.2.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::calculateVisibility()

Calculate the new visibility options.

Parameters

string $current_visibility: The current visibility.

array $new_options: The new options to choose from.

Return value

string The new visibility.

1 call to FlexibleGroupContentVisibilityUpdate::calculateVisibility()
FlexibleGroupContentVisibilityUpdate::updateVisibility in modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php
Update visibility for all Group Content based on a new group type.

File

modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php, line 213

Class

FlexibleGroupContentVisibilityUpdate
Class FlexibleGroupContentVisibilityUpdate.

Namespace

Drupal\social_group_flexible_group

Code

public static function calculateVisibility($current_visibility, array $new_options) {

  // If there is only one option just return that one.
  if (count($new_options) === 1) {
    return $new_options[0]['value'];
  }
  $visibility = '';

  // Calculate new options based on what it was before editting.
  switch ($current_visibility) {
    case 'community':
      $visibility = 'public';
      if (array_search('group', array_column($new_options, 'value')) !== FALSE) {
        $visibility = 'group';
      }
      break;
    case 'public':
      $visibility = 'group';
      if (array_search('community', array_column($new_options, 'value')) !== FALSE) {
        $visibility = 'community';
      }
      break;
    case 'group':
      $visibility = 'public';
      if (array_search('community', array_column($new_options, 'value')) !== FALSE) {
        $visibility = 'community';
      }
      break;
  }
  return $visibility;
}