function _social_post_mass_update_helper in Open Social 8.3
Same name and namespace in other branches
- 8.9 modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 8.4 modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 8.5 modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 8.6 modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 8.7 modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 8.8 modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 10.3.x modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 10.0.x modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 10.1.x modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
- 10.2.x modules/social_features/social_post/social_post.admin.inc \_social_post_mass_update_helper()
Updates individual posts when fewer than 10 are queued.
Parameters
\Drupal\social_post\Entity\PostInterface $post: A post to update.
array $updates: Associative array of updates.
string $langcode: (optional) The language updates should be applied to. If none is specified all available languages are processed.
Return value
\Drupal\social_post\Entity\PostInterface An updated post object.
See also
2 calls to _social_post_mass_update_helper()
- social_post_mass_update in modules/
social_features/ social_post/ social_post.admin.inc - Updates all posts in the passed-in array with the passed-in field values.
- _social_post_mass_update_batch_process in modules/
social_features/ social_post/ social_post.admin.inc - Implements callback_batch_operation().
File
- modules/
social_features/ social_post/ social_post.admin.inc, line 80 - Helper methods for post administration actions.
Code
function _social_post_mass_update_helper(PostInterface $post, array $updates, $langcode = NULL) {
$langcodes = isset($langcode) ? [
$langcode,
] : array_keys($post
->getTranslationLanguages());
// For efficiency manually save the original post before applying any changes.
$post->original = clone $post;
foreach ($langcodes as $langcode) {
foreach ($updates as $name => $value) {
$post
->getTranslation($langcode)->{$name} = $value;
}
}
$post
->save();
return $post;
}