function social_install_demo_content in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 social.profile \social_install_demo_content()
- 8.8 social.profile \social_install_demo_content()
- 10.3.x social.profile \social_install_demo_content()
- 10.0.x social.profile \social_install_demo_content()
- 10.1.x social.profile \social_install_demo_content()
Uses the Social Demo module to install demo content.
Will enable the Social Demo module, install the content and then disable the Social Demo module again because it's only a helper to create the content.
Parameters
array $install_state: The install state.
Return value
array Batch settings.
2 string references to 'social_install_demo_content'
- ModuleConfigureForm::submitForm in src/
Installer/ Form/ ModuleConfigureForm.php - Form submission handler.
- social_install_tasks in ./
social.profile - Implements hook_install_tasks().
File
- ./
social.profile, line 105 - Enables modules and site configuration for a social site installation.
Code
function social_install_demo_content(array &$install_state) {
// Clear all status messages generated by modules installed in previous steps.
Drupal::service('messenger')
->deleteByType('status');
// There is no content at this point.
node_access_needs_rebuild(FALSE);
$batch = [];
// Enable the social_demo module.
$batch['operations'][] = [
'_social_install_module_batch',
[
[
'social_demo',
],
'social_demo',
],
];
// Generate demo content.
$demo_content_types = [
'file' => t('files'),
'user' => t('users'),
'group' => t('groups'),
'topic' => t('topics'),
'event' => t('events'),
'event_enrollment' => t('event enrollments'),
'post' => t('posts'),
'comment' => t('comments'),
'like' => t('likes'),
];
foreach ($demo_content_types as $demo_type => $demo_description) {
$batch['operations'][] = [
'_social_add_demo_batch',
[
$demo_type,
$demo_description,
],
];
}
// Uninstall social_demo.
$batch['operations'][] = [
'_social_uninstall_module_batch',
[
[
'social_demo',
],
'social_demo',
],
];
$batch['operations'][] = [
'_social_index_demo_content',
];
return $batch;
}