function _social_post_photo_settype in Open Social 8.9
Same name and namespace in other branches
- 8 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 8.2 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 8.3 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 8.4 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 8.5 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 8.6 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 8.7 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 8.8 modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 10.3.x modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 10.0.x modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 10.1.x modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
- 10.2.x modules/social_features/social_post/modules/social_post_photo/social_post_photo.module \_social_post_photo_settype()
Function to change the post type.
Parameters
string $from: Type to change it from.
string $to: Type to change it to.
2 calls to _social_post_photo_settype()
- social_post_photo_install in modules/
social_features/ social_post/ modules/ social_post_photo/ social_post_photo.install - Install hook for Social Post Photo.
- social_post_photo_uninstall in modules/
social_features/ social_post/ modules/ social_post_photo/ social_post_photo.install - Uninstall hook for Social Post Photo.
File
- modules/
social_features/ social_post/ modules/ social_post_photo/ social_post_photo.module, line 43 - The Social post photo module.
Code
function _social_post_photo_settype($from, $to) {
// Get post storage.
$poststorage = \Drupal::entityTypeManager()
->getStorage('post');
// Load all posts of type post.
$posts = $poststorage
->loadByProperties([
'type' => $from,
]);
/** @var \Drupal\social_post\Entity\Post $post */
foreach ($posts as $post) {
$post
->set('type', $to)
->save();
}
}