public static function FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
- 8.6 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
- 8.7 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
- 8.8 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
- 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
- 10.0.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
- 10.1.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
Update Group content after Group changed.
Parameters
\Drupal\group\Entity\GroupInterface $group: The Group we've updated.
array $changed_visibility: The Group's old visibility.
array $new_options: The Group's new visibility options.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility()
- _social_flexible_group_edit_submit in modules/
social_features/ social_group/ modules/ social_group_flexible_group/ social_group_flexible_group.module - Custom form submit handler for editing a flexible group.
File
- modules/
social_features/ social_group/ modules/ social_group_flexible_group/ src/ FlexibleGroupContentVisibilityUpdate.php, line 63
Class
- FlexibleGroupContentVisibilityUpdate
- Class FlexibleGroupContentVisibilityUpdate.
Namespace
Drupal\social_group_flexible_groupCode
public static function batchUpdateGroupContentVisibility(GroupInterface $group, array $changed_visibility, array $new_options) {
// Set it up as a batch. We need to update visibility.
// Load all the GroupContentEntities from Post to content.
// Memberships don't need an update.
$entities = $posts = [];
$entities = $group
->getContentEntities();
$posts = self::getPostsFromGroup($group);
// Add posts to the entities we need to update based on visibility.
if (!empty($posts)) {
foreach ($posts as $pid => $post) {
if (in_array($post
->getVisibility(), $changed_visibility, FALSE)) {
$entities[] = $post;
}
}
}
$num_operations = count($entities);
$operations = [];
// Update ContentVisibility.
// As per documentation each entity has it's own operation.
for ($i = 0; $i < $num_operations; $i++) {
$operations[] = [
'\\Drupal\\social_group_flexible_group\\FlexibleGroupContentVisibilityUpdate::updateVisibility',
[
$entities[$i],
$new_options,
],
];
}
// Provide all the operations and the finish callback to our batch.
$batch = [
'title' => t('Updating Group Content...'),
'operations' => $operations,
'finished' => '\\Drupal\\social_group_flexible_group\\FlexibleGroupContentVisibilityUpdate::updateVisibilityFinishedCallback',
];
batch_set($batch);
}