<?php

/**
 * @file
 * Install, update and uninstall functions for the social_event module.
 */

use Drupal\Core\Config\ConfigException;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Site\Settings;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldConfigInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
use Symfony\Component\Yaml\Yaml;

/**
 * Implements hook_install().
 *
 * Perform actions related to the installation of social_event.
 */
function social_event_install() {
  // Grant the default permissions for this feature.
  user_role_grant_permissions(
    RoleInterface::ANONYMOUS_ID,
    [
      'view node.event.field_content_visibility:public content',
    ]
  );
  user_role_grant_permissions(
    RoleInterface::AUTHENTICATED_ID,
    [
      'view node.event.field_content_visibility:public content',
    ]
  );
  user_role_grant_permissions(
    'verified',
    [
      'create event content',
      'delete own event content',
      'edit own event content',
      'override event published option',
      'view node.event.field_content_visibility:community content',
      'view events on my profile',
      'view events on other profiles',
    ]
  );
  user_role_grant_permissions(
    'contentmanager',
    [
      'create event content',
      'delete own event content',
      'edit own event content',
      'override event published option',
      'view node.event.field_content_visibility:community content',
      'view events on my profile',
      'view events on other profiles',
      'delete any event content',
      'edit any event content',
      'revert event revisions',
      'delete event revisions',
      'view event revisions',
      'override event authored by option',
      'override event authored on option',
      'override event promote to front page option',
      'override event revision option',
      'override event sticky option',
    ]
  );
  user_role_grant_permissions(
    'sitemanager',
    [
      'create event content',
      'delete own event content',
      'edit own event content',
      'override event published option',
      'view node.event.field_content_visibility:community content',
      'view events on my profile',
      'view events on other profiles',
      'delete any event content',
      'edit any event content',
      'revert event revisions',
      'delete event revisions',
      'view event revisions',
      'override event authored by option',
      'override event authored on option',
      'override event promote to front page option',
      'override event revision option',
      'override event sticky option',
      'administer visibility settings',
      'administer social_event settings',
      'view published event enrollment entities',
    ]
  );
  // Add menu links.
  $parents = \Drupal::entityTypeManager()->getStorage('menu_link_content')
    ->loadByProperties(['menu_name' => 'main', 'title' => 'Explore', 'expanded' => TRUE]);
  $parent = reset($parents);
  if ($parent !== FALSE) {
    MenuLinkContent::create([
      'title' => t('All events'),
      'link' => ['uri' => 'internal:/community-events'],
      'menu_name' => 'main',
      'expanded' => FALSE,
      'weight' => 30,
      'parent' => 'menu_link_content:' . $parent->uuid(),
    ])->save();
  }
}

/**
 * Implements hook_update_dependencies().
 */
function social_event_update_dependencies() {
  // New config changes should run after the features removal/revert.
  $dependencies['social_event'][8802] = [
    'social_core' => 8805,
  ];

  // New image style change should run after the new image style is imported.
  $dependencies['social_event'][8915] = [
    'social_core' => 8908,
  ];

  $dependencies['social_event'][11401] = [
    'social_core' => 11401,
  ];

  $dependencies['social_event'][11403] = [
    'group' => 8020,
  ];

  return $dependencies;
}

/**
 * Enable event enrolling of open groups for not member.
 */
function social_event_update_8001() {
  \Drupal::configFactory()->getEditable('social_event.settings')
    ->set('enroll', [])
    ->save();
}

/**
 * Set permissions to administer social_event settings.
 */
function social_event_update_8002() {
  // Give SM the administer social_event settings permission.
  user_role_grant_permissions('sitemanager', ['administer social_event settings']);
}

/**
 * Set my events permissions.
 */
function social_event_update_8003() {
  // Make it so that everyone who has the 'access user profiles' permission,
  // now also get these two new permissions.
  $permissions = [
    'view events on my profile',
    'view events on other profiles',
  ];

  /** @var \Drupal\user\Entity\Role $role */
  foreach (Role::loadMultiple() as $role) {
    if ($role->hasPermission('access user profiles')) {
      user_role_grant_permissions($role->id(), $permissions);
    }
  }
}

/**
 * Fix empty value in enroll setting.
 */
function social_event_update_8801() {
  // This does not need to run before 8802 necessarily because the
  // features_removal/ folder has also been updated so a revert works too.
  // This update mostly exists for people who've already updated to 8.0.
  $settings = \Drupal::configFactory()->getEditable('social_event.settings');
  $enroll = $settings->get('enroll');
  // Only change it if no value was set yet.
  if (empty($enroll)) {
    $settings->set('enroll', [])->save();
  }
}

/**
 * Remove public group from event.small_teaser.
 */
function social_event_update_8802() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8802');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update view mode for new small teaser style.
 */
function social_event_update_8803() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8803');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Fix small teaser view mode after accidental regression for some sites.
 */
function social_event_update_8804() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8804');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Install new fields for the request to join event.
 */
function social_event_update_8805(&$sandbox) {
  if (!isset($sandbox['total'])) {

    // Install new fields:
    // - event_enrollment.field_request_or_invite_status.
    // - field_enroll_method.
    // - field_event_enroll_outside_group.
    // - event_enrollment.field_request_message.
    $sandbox['configs'] = [
      'field.storage.event_enrollment.field_request_or_invite_status' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'module' => [
            'options',
            'social_event',
          ],
        ],
        'id' => 'event_enrollment.field_request_or_invite_status',
        'field_name' => 'field_request_or_invite_status',
        'entity_type' => 'event_enrollment',
        'type' => 'list_integer',
        'settings' => [
          'allowed_values' => [
            [
              'value' => 0,
              'label' => t('Pending'),
            ],
            [
              'value' => 1,
              'label' => t('Approved'),
            ],
            [
              'value' => 2,
              'label' => t('Declined'),
            ],
            [
              'value' => 3,
              'label' => t('Invited'),
            ],
            [
              'value' => 4,
              'label' => t('Pending reply'),
            ],
            [
              'value' => 5,
              'label' => t('Accepted and joined'),
            ],
            [
              'value' => 6,
              'label' => t('Invalid or expired'),
            ],
          ],
          'allowed_values_function' => '',
        ],
        'module' => 'options',
        'locked' => FALSE,
        'cardinality' => 1,
        'translatable' => TRUE,
        'indexes' => [],
        'persist_with_no_fields' => FALSE,
        'custom_storage' => FALSE,
      ],
      'field.field.event_enrollment.event_enrollment.field_request_or_invite_status' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'config' => [
            'field.storage.event_enrollment.field_request_or_invite_status',
          ],
          'module' => [
            'options',
            'social_event',
          ],
        ],
        'id' => 'event_enrollment.event_enrollment.field_request_or_invite_status',
        'field_name' => 'field_request_or_invite_status',
        'entity_type' => 'event_enrollment',
        'bundle' => 'event_enrollment',
        'label' => t('Request or invite status'),
        'description' => '',
        'required' => FALSE,
        'translatable' => FALSE,
        'default_value' => [],
        'default_value_callback' => '',
        'settings' => [],
        'field_type' => 'list_integer',
      ],
      'field.storage.node.field_enroll_method' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'module' => [
            'node',
            'options',
          ],
        ],
        'id' => 'node.field_enroll_method',
        'field_name' => 'field_enroll_method',
        'entity_type' => 'node',
        'type' => 'list_integer',
        'settings' => [
          'allowed_values' => [
            0 => [
              'value' => 1,
              'label' => t('Open to enroll - users can enroll for this event without approval'),
            ],
            1 => [
              'value' => 2,
              'label' => t('Request to enroll - users can "request to enroll" for this event which event organisers approve/decline'),
            ],
            2 => [
              'value' => 3,
              'label' => t('Invite-only - users can only enroll for this event if they are added/invited by event organisers'),
            ],
          ],
          'allowed_values_function' => '',
        ],
        'module' => 'options',
        'locked' => FALSE,
        'cardinality' => 1,
        'translatable' => TRUE,
        'indexes' => [],
        'persist_with_no_fields' => FALSE,
        'custom_storage' => FALSE,
      ],
      'field.field.node.event.field_enroll_method' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'config' => [
            'field.storage.node.field_enroll_method',
            'node.type.event',
          ],
          'module' => [
            'options',
          ],
        ],
        'id' => 'node.event.field_enroll_method',
        'field_name' => 'field_enroll_method',
        'entity_type' => 'node',
        'bundle' => 'event',
        'label' => t('Enroll Method'),
        'description' => '',
        'required' => TRUE,
        'translatable' => FALSE,
        'default_value' =>
          [
            0 => [
              'value' => 1,
            ],
          ],
        'default_value_callback' => '',
        'settings' => [],
        'field_type' => 'list_integer',
      ],
      'field.storage.node.field_event_enroll_outside_group' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'module' => [
            'node',
          ],
        ],
        'id' => 'node.field_event_enroll_outside_group',
        'field_name' => 'field_event_enroll_outside_group',
        'entity_type' => 'node',
        'type' => 'boolean',
        'settings' => [],
        'module' => 'core',
        'locked' => FALSE,
        'cardinality' => 1,
        'translatable' => TRUE,
        'indexes' => [],
        'persist_with_no_fields' => FALSE,
        'custom_storage' => FALSE,
      ],
      'field.field.node.event.field_event_enroll_outside_group' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'config' => [
            'field.storage.node.field_event_enroll_outside_group',
            'node.type.event',
          ],
        ],
        'id' => 'node.event.field_event_enroll_outside_group',
        'field_name' => 'field_event_enroll_outside_group',
        'entity_type' => 'node',
        'bundle' => 'event',
        'label' => t('Allow non-group members to enroll or request to enroll'),
        'description' => 'To allow users who have not join the group of this event to enroll or send request to enroll',
        'required' => FALSE,
        'translatable' => FALSE,
        'default_value' => [
          0 => [
            'value' => 0,
          ],
        ],
        'default_value_callback' => '',
        'settings' => [
          'on_label' => 'On',
          'off_label' => 'Off',
        ],
        'field_type' => 'boolean',
      ],
      'field.storage.event_enrollment.field_request_message' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'module' => [
            'social_event',
          ],
        ],
        'id' => 'event_enrollment.field_request_message',
        'field_name' => 'field_request_message',
        'entity_type' => 'event_enrollment',
        'type' => 'string_long',
        'settings' => [
          'case_sensitive' => FALSE,
        ],
        'module' => 'core',
        'locked' => FALSE,
        'cardinality' => 1,
        'translatable' => TRUE,
        'indexes' => [],
        'persist_with_no_fields' => FALSE,
        'custom_storage' => FALSE,
      ],
      'field.field.event_enrollment.event_enrollment.field_request_message' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'config' => [
            'field.storage.event_enrollment.field_request_message',
          ],
          'module' => [
            'social_event',
          ],
        ],
        'id' => 'event_enrollment.event_enrollment.field_request_message',
        'field_name' => 'field_request_message',
        'entity_type' => 'event_enrollment',
        'bundle' => 'event_enrollment',
        'label' => t('Request message'),
        'description' => 'You can leave a message in your request. Once your request is approved, you will receive a notification via email and notification center.',
        'required' => FALSE,
        'translatable' => FALSE,
        'default_value' => [],
        'default_value_callback' => '',
        'settings' => [],
        'field_type' => 'string_long',
      ],
      // New views.
      'views.view.event_manage_enrollment_requests' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'config' => [
            'core.entity_view_mode.profile.table',
            'field.storage.event_enrollment.field_request_message',
            'field.storage.event_enrollment.field_request_or_invite_status',
            'field.storage.profile.field_profile_organization',
            'node.type.event',
          ],
          'module' => [
            'node',
            'options',
            'profile',
            'social_event',
            'user',
          ],
        ],
        'id' => 'event_manage_enrollment_requests',
        'label' => t('Manage event enrollment requests'),
        'module' => 'views',
        'description' => '',
        'tag' => '',
        'base_table' => 'event_enrollment_field_data',
        'base_field' => 'id',
        'display' => [
          'default' => [
            'display_plugin' => 'default',
            'id' => 'default',
            'display_title' => 'Master',
            'position' => 0,
            'display_options' => [
              'access' => [
                'type' => 'none',
                'options' => [],
              ],
              'cache' => [
                'type' => 'tag',
                'options' => [],
              ],
              'query' => [
                'type' => 'views_query',
                'options' => [
                  'disable_sql_rewrite' => FALSE,
                  'distinct' => FALSE,
                  'replica' => FALSE,
                  'query_comment' => '',
                  'query_tags' => [],
                ],
              ],
              'exposed_form' => [
                'type' => 'basic',
                'options' => [
                  'submit_button' => 'Apply',
                  'reset_button' => FALSE,
                  'reset_button_label' => 'Reset',
                  'exposed_sorts_label' => 'Sort by',
                  'expose_sort_order' => TRUE,
                  'sort_asc_label' => 'Asc',
                  'sort_desc_label' => 'Desc',
                ],
              ],
              'pager' => [
                'type' => 'full',
                'options' => [
                  'items_per_page' => 10,
                  'offset' => 0,
                  'id' => 0,
                  'total_pages' => NULL,
                  'tags' => [
                    'previous' => '‹ Previous',
                    'next' => 'Next ›',
                    'first' => '« First',
                    'last' => 'Last »',
                  ],
                  'expose' => [
                    'items_per_page' => FALSE,
                    'items_per_page_label' => 'Items per page',
                    'items_per_page_options' => '5, 10, 25, 50',
                    'items_per_page_options_all' => FALSE,
                    'items_per_page_options_all_label' => '- All -',
                    'offset' => FALSE,
                    'offset_label' => 'Offset',
                  ],
                  'quantity' => 9,
                ],
              ],
              'style' => [
                'type' => 'table',
                'options' => [
                  'grouping' => [],
                  'row_class' => '',
                  'default_row_class' => TRUE,
                  'override' => TRUE,
                  'sticky' => FALSE,
                  'caption' => '',
                  'summary' => '',
                  'description' => '',
                  'columns' => [
                    'rendered_entity' => 'rendered_entity',
                    'field_profile_organization' => 'field_profile_organization',
                    'field_request_message' => 'field_request_message',
                    'field_request_or_invite_status' => 'field_request_or_invite_status',
                    'created' => 'created',
                    'operations_1' => 'operations_1',
                  ],
                  'info' => [
                    'rendered_entity' => [
                      'sortable' => FALSE,
                      'default_sort_order' => 'asc',
                      'align' => '',
                      'separator' => '',
                      'empty_column' => FALSE,
                      'responsive' => '',
                    ],
                    'field_profile_organization' => [
                      'sortable' => TRUE,
                      'default_sort_order' => 'asc',
                      'align' => '',
                      'separator' => '',
                      'empty_column' => FALSE,
                      'responsive' => '',
                    ],
                    'field_request_message' => [
                      'sortable' => FALSE,
                      'default_sort_order' => 'asc',
                      'align' => '',
                      'separator' => '',
                      'empty_column' => FALSE,
                      'responsive' => '',
                    ],
                    'field_request_or_invite_status' => [
                      'sortable' => TRUE,
                      'default_sort_order' => 'asc',
                      'align' => '',
                      'separator' => '',
                      'empty_column' => FALSE,
                      'responsive' => '',
                    ],
                    'created' => [
                      'sortable' => TRUE,
                      'default_sort_order' => 'asc',
                      'align' => '',
                      'separator' => '',
                      'empty_column' => FALSE,
                      'responsive' => '',
                    ],
                    'operations_1' => [
                      'align' => '',
                      'separator' => '',
                      'empty_column' => FALSE,
                      'responsive' => '',
                    ],
                  ],
                  'default' => '-1',
                  'empty_table' => TRUE,
                ],
              ],
              'row' => [
                'type' => 'fields',
              ],
              'fields' => [
                'rendered_entity' => [
                  'id' => 'rendered_entity',
                  'table' => 'profile',
                  'field' => 'rendered_entity',
                  'relationship' => 'profile',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'label' => t('Enrollee'),
                  'exclude' => FALSE,
                  'alter' => [
                    'alter_text' => FALSE,
                    'text' => '',
                    'make_link' => FALSE,
                    'path' => '',
                    'absolute' => FALSE,
                    'external' => FALSE,
                    'replace_spaces' => FALSE,
                    'path_case' => 'none',
                    'trim_whitespace' => FALSE,
                    'alt' => '',
                    'rel' => '',
                    'link_class' => '',
                    'prefix' => '',
                    'suffix' => '',
                    'target' => '',
                    'nl2br' => FALSE,
                    'max_length' => 0,
                    'word_boundary' => TRUE,
                    'ellipsis' => TRUE,
                    'more_link' => FALSE,
                    'more_link_text' => '',
                    'more_link_path' => '',
                    'strip_tags' => FALSE,
                    'trim' => FALSE,
                    'preserve_tags' => '',
                    'html' => FALSE,
                  ],
                  'element_type' => '',
                  'element_class' => '',
                  'element_label_type' => '',
                  'element_label_class' => '',
                  'element_label_colon' => TRUE,
                  'element_wrapper_type' => '',
                  'element_wrapper_class' => '',
                  'element_default_classes' => TRUE,
                  'empty' => '-',
                  'hide_empty' => FALSE,
                  'empty_zero' => FALSE,
                  'hide_alter_empty' => TRUE,
                  'view_mode' => 'table',
                  'entity_type' => 'profile',
                  'plugin_id' => 'rendered_entity',
                ],
                'field_profile_organization' => [
                  'id' => 'field_profile_organization',
                  'table' => 'profile__field_profile_organization',
                  'field' => 'field_profile_organization',
                  'relationship' => 'profile',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'label' => t('Organization'),
                  'exclude' => FALSE,
                  'alter' => [
                    'alter_text' => FALSE,
                    'text' => '',
                    'make_link' => FALSE,
                    'path' => '',
                    'absolute' => FALSE,
                    'external' => FALSE,
                    'replace_spaces' => FALSE,
                    'path_case' => 'none',
                    'trim_whitespace' => FALSE,
                    'alt' => '',
                    'rel' => '',
                    'link_class' => '',
                    'prefix' => '',
                    'suffix' => '',
                    'target' => '',
                    'nl2br' => FALSE,
                    'max_length' => 0,
                    'word_boundary' => TRUE,
                    'ellipsis' => TRUE,
                    'more_link' => FALSE,
                    'more_link_text' => '',
                    'more_link_path' => '',
                    'strip_tags' => FALSE,
                    'trim' => FALSE,
                    'preserve_tags' => '',
                    'html' => FALSE,
                  ],
                  'element_type' => '',
                  'element_class' => '',
                  'element_label_type' => '',
                  'element_label_class' => '',
                  'element_label_colon' => TRUE,
                  'element_wrapper_type' => '',
                  'element_wrapper_class' => '',
                  'element_default_classes' => TRUE,
                  'empty' => '-',
                  'hide_empty' => FALSE,
                  'empty_zero' => FALSE,
                  'hide_alter_empty' => TRUE,
                  'click_sort_column' => 'value',
                  'type' => 'string',
                  'settings' => [
                    'link_to_entity' => FALSE,
                  ],
                  'group_column' => 'value',
                  'group_columns' => [],
                  'group_rows' => TRUE,
                  'delta_limit' => 0,
                  'delta_offset' => 0,
                  'delta_reversed' => FALSE,
                  'delta_first_last' => FALSE,
                  'multi_type' => 'separator',
                  'separator' => ', ',
                  'field_api_classes' => FALSE,
                  'plugin_id' => 'field',
                ],
                'field_request_message' => [
                  'id' => 'field_request_message',
                  'table' => 'event_enrollment__field_request_message',
                  'field' => 'field_request_message',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'label' => t('Message'),
                  'exclude' => FALSE,
                  'alter' => [
                    'alter_text' => FALSE,
                    'text' => '',
                    'make_link' => FALSE,
                    'path' => '',
                    'absolute' => FALSE,
                    'external' => FALSE,
                    'replace_spaces' => FALSE,
                    'path_case' => 'none',
                    'trim_whitespace' => FALSE,
                    'alt' => '',
                    'rel' => '',
                    'link_class' => '',
                    'prefix' => '',
                    'suffix' => '',
                    'target' => '',
                    'nl2br' => FALSE,
                    'max_length' => 0,
                    'word_boundary' => TRUE,
                    'ellipsis' => TRUE,
                    'more_link' => FALSE,
                    'more_link_text' => '',
                    'more_link_path' => '',
                    'strip_tags' => FALSE,
                    'trim' => FALSE,
                    'preserve_tags' => '',
                    'html' => FALSE,
                  ],
                  'element_type' => '',
                  'element_class' => '',
                  'element_label_type' => '',
                  'element_label_class' => '',
                  'element_label_colon' => FALSE,
                  'element_wrapper_type' => '',
                  'element_wrapper_class' => '',
                  'element_default_classes' => TRUE,
                  'empty' => '',
                  'hide_empty' => FALSE,
                  'empty_zero' => FALSE,
                  'hide_alter_empty' => TRUE,
                  'click_sort_column' => 'value',
                  'type' => 'basic_string',
                  'settings' => [],
                  'group_column' => 'value',
                  'group_columns' => [],
                  'group_rows' => TRUE,
                  'delta_limit' => 0,
                  'delta_offset' => 0,
                  'delta_reversed' => FALSE,
                  'delta_first_last' => FALSE,
                  'multi_type' => 'separator',
                  'separator' => ', ',
                  'field_api_classes' => FALSE,
                  'plugin_id' => 'field',
                ],
                'field_request_or_invite_status' => [
                  'id' => 'field_request_or_invite_status',
                  'table' => 'event_enrollment__field_request_or_invite_status',
                  'field' => 'field_request_or_invite_status',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'label' => t('Request status'),
                  'exclude' => FALSE,
                  'alter' => [
                    'alter_text' => FALSE,
                    'text' => '',
                    'make_link' => FALSE,
                    'path' => '',
                    'absolute' => FALSE,
                    'external' => FALSE,
                    'replace_spaces' => FALSE,
                    'path_case' => 'none',
                    'trim_whitespace' => FALSE,
                    'alt' => '',
                    'rel' => '',
                    'link_class' => '',
                    'prefix' => '',
                    'suffix' => '',
                    'target' => '',
                    'nl2br' => FALSE,
                    'max_length' => 0,
                    'word_boundary' => TRUE,
                    'ellipsis' => TRUE,
                    'more_link' => FALSE,
                    'more_link_text' => '',
                    'more_link_path' => '',
                    'strip_tags' => FALSE,
                    'trim' => FALSE,
                    'preserve_tags' => '',
                    'html' => FALSE,
                  ],
                  'element_type' => '',
                  'element_class' => '',
                  'element_label_type' => '',
                  'element_label_class' => '',
                  'element_label_colon' => TRUE,
                  'element_wrapper_type' => '',
                  'element_wrapper_class' => '',
                  'element_default_classes' => TRUE,
                  'empty' => '',
                  'hide_empty' => FALSE,
                  'empty_zero' => FALSE,
                  'hide_alter_empty' => TRUE,
                  'click_sort_column' => 'value',
                  'type' => 'list_default',
                  'settings' => [],
                  'group_column' => 'value',
                  'group_columns' => [],
                  'group_rows' => TRUE,
                  'delta_limit' => 0,
                  'delta_offset' => 0,
                  'delta_reversed' => FALSE,
                  'delta_first_last' => FALSE,
                  'multi_type' => 'separator',
                  'separator' => ', ',
                  'field_api_classes' => FALSE,
                  'plugin_id' => 'field',
                ],
                'created' => [
                  'id' => 'created',
                  'table' => 'event_enrollment_field_data',
                  'field' => 'created',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'label' => t('Requested on'),
                  'exclude' => FALSE,
                  'alter' => [
                    'alter_text' => FALSE,
                    'text' => '',
                    'make_link' => FALSE,
                    'path' => '',
                    'absolute' => FALSE,
                    'external' => FALSE,
                    'replace_spaces' => FALSE,
                    'path_case' => 'none',
                    'trim_whitespace' => FALSE,
                    'alt' => '',
                    'rel' => '',
                    'link_class' => '',
                    'prefix' => '',
                    'suffix' => '',
                    'target' => '',
                    'nl2br' => FALSE,
                    'max_length' => 0,
                    'word_boundary' => TRUE,
                    'ellipsis' => TRUE,
                    'more_link' => FALSE,
                    'more_link_text' => '',
                    'more_link_path' => '',
                    'strip_tags' => FALSE,
                    'trim' => FALSE,
                    'preserve_tags' => '',
                    'html' => FALSE,
                  ],
                  'element_type' => '',
                  'element_class' => '',
                  'element_label_type' => '',
                  'element_label_class' => '',
                  'element_label_colon' => TRUE,
                  'element_wrapper_type' => '',
                  'element_wrapper_class' => '',
                  'element_default_classes' => TRUE,
                  'empty' => '',
                  'hide_empty' => FALSE,
                  'empty_zero' => FALSE,
                  'hide_alter_empty' => TRUE,
                  'click_sort_column' => 'value',
                  'type' => 'timestamp',
                  'settings' => [
                    'date_format' => 'social_long_date',
                    'custom_date_format' => '',
                    'timezone' => '',
                  ],
                  'group_column' => 'value',
                  'group_columns' => [],
                  'group_rows' => TRUE,
                  'delta_limit' => 0,
                  'delta_offset' => 0,
                  'delta_reversed' => FALSE,
                  'delta_first_last' => FALSE,
                  'multi_type' => 'separator',
                  'separator' => ', ',
                  'field_api_classes' => FALSE,
                  'entity_type' => 'event_enrollment',
                  'entity_field' => 'created',
                  'plugin_id' => 'field',
                ],
                'operations_1' => [
                  'id' => 'operations_1',
                  'table' => 'event_enrollment',
                  'field' => 'operations',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'label' => t('Operation'),
                  'exclude' => FALSE,
                  'alter' => [
                    'alter_text' => FALSE,
                    'text' => '',
                    'make_link' => FALSE,
                    'path' => '',
                    'absolute' => FALSE,
                    'external' => FALSE,
                    'replace_spaces' => FALSE,
                    'path_case' => 'none',
                    'trim_whitespace' => FALSE,
                    'alt' => '',
                    'rel' => '',
                    'link_class' => '',
                    'prefix' => '',
                    'suffix' => '',
                    'target' => '',
                    'nl2br' => FALSE,
                    'max_length' => 0,
                    'word_boundary' => TRUE,
                    'ellipsis' => TRUE,
                    'more_link' => FALSE,
                    'more_link_text' => '',
                    'more_link_path' => '',
                    'strip_tags' => FALSE,
                    'trim' => FALSE,
                    'preserve_tags' => '',
                    'html' => FALSE,
                  ],
                  'element_type' => '',
                  'element_class' => '',
                  'element_label_type' => '',
                  'element_label_class' => '',
                  'element_label_colon' => TRUE,
                  'element_wrapper_type' => '',
                  'element_wrapper_class' => '',
                  'element_default_classes' => TRUE,
                  'empty' => '',
                  'hide_empty' => FALSE,
                  'empty_zero' => FALSE,
                  'hide_alter_empty' => TRUE,
                  'destination' => TRUE,
                  'entity_type' => 'event_enrollment',
                  'plugin_id' => 'entity_operations',
                ],
              ],
              'filters' => [
                'type' => [
                  'id' => 'type',
                  'table' => 'node_field_data',
                  'field' => 'type',
                  'relationship' => 'field_event',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'operator' => 'in',
                  'value' => [
                    'event' => 'event',
                  ],
                  'group' => 1,
                  'exposed' => FALSE,
                  'expose' => [
                    'operator_id' => '',
                    'label' => '',
                    'description' => '',
                    'use_operator' => FALSE,
                    'operator' => '',
                    'identifier' => '',
                    'required' => FALSE,
                    'remember' => FALSE,
                    'multiple' => FALSE,
                    'remember_roles' => [
                      'authenticated' => 'authenticated',
                    ],
                    'reduce' => FALSE,
                    'operator_limit_selection' => FALSE,
                    'operator_list' => [],
                  ],
                  'is_grouped' => FALSE,
                  'group_info' => [
                    'label' => '',
                    'description' => '',
                    'identifier' => '',
                    'optional' => TRUE,
                    'widget' => 'select',
                    'multiple' => FALSE,
                    'remember' => FALSE,
                    'default_group' => 'All',
                    'default_group_multiple' => [],
                    'group_items' => [],
                  ],
                  'entity_type' => 'node',
                  'entity_field' => 'type',
                  'plugin_id' => 'bundle',
                ],
                'field_request_or_invite_status_value' => [
                  'id' => 'field_request_or_invite_status_value',
                  'table' => 'event_enrollment__field_request_or_invite_status',
                  'field' => 'field_request_or_invite_status_value',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'operator' => 'or',
                  'value' => [
                    '0',
                  ],
                  'group' => 1,
                  'exposed' => FALSE,
                  'expose' => [
                    'operator_id' => '',
                    'label' => '',
                    'description' => '',
                    'use_operator' => FALSE,
                    'operator' => '',
                    'operator_limit_selection' => FALSE,
                    'operator_list' => [],
                    'identifier' => '',
                    'required' => FALSE,
                    'remember' => FALSE,
                    'multiple' => FALSE,
                    'remember_roles' => [
                      'authenticated' => 'authenticated',
                    ],
                    'reduce' => FALSE,
                  ],
                  'is_grouped' => FALSE,
                  'group_info' => [
                    'label' => '',
                    'description' => '',
                    'identifier' => '',
                    'optional' => TRUE,
                    'widget' => 'select',
                    'multiple' => FALSE,
                    'remember' => FALSE,
                    'default_group' => 'All',
                    'default_group_multiple' => [],
                    'group_items' => [],
                  ],
                  'reduce_duplicates' => FALSE,
                  'plugin_id' => 'list_field',
                ],
              ],
              'sorts' => [
                'created' => [
                  'id' => 'created',
                  'table' => 'event_enrollment_field_data',
                  'field' => 'created',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'order' => 'DESC',
                  'exposed' => FALSE,
                  'expose' => [
                    'label' => '',
                  ],
                  'granularity' => 'second',
                  'entity_type' => 'event_enrollment',
                  'entity_field' => 'created',
                  'plugin_id' => 'date',
                ],
                'field_request_or_invite_status_value' => [
                  'id' => 'field_request_or_invite_status_value',
                  'table' => 'event_enrollment__field_request_or_invite_status',
                  'field' => 'field_request_or_invite_status_value',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'order' => 'DESC',
                  'exposed' => FALSE,
                  'expose' => [
                    'label' => '',
                  ],
                  'plugin_id' => 'standard',
                ],
              ],
              'title' => t('Manage enrollment requests'),
              'header' => [
                'area' => [
                  'id' => 'area',
                  'table' => 'views',
                  'field' => 'area',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'empty' => TRUE,
                  'tokenize' => TRUE,
                  'content' => [
                    'value' => '<h1 class="h4 section-title">[view:total-rows] Enroll request(s) to event: {{ arguments.nid }}</h1>',
                    'format' => 'full_html',
                  ],
                  'plugin_id' => 'text',
                ],
              ],
              'footer' => [],
              'empty' => [
                'area_text_custom' => [
                  'id' => 'area_text_custom',
                  'table' => 'views',
                  'field' => 'area_text_custom',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'empty' => TRUE,
                  'tokenize' => FALSE,
                  'content' => 'No one has requested to be enrolled for this event yet.',
                  'plugin_id' => 'text_custom',
                ],
              ],
              'relationships' => [
                'field_event' => [
                  'id' => 'field_event',
                  'table' => 'event_enrollment__field_event',
                  'field' => 'field_event',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => 'field_event: Content',
                  'required' => TRUE,
                  'plugin_id' => 'standard',
                ],
                'field_account' => [
                  'id' => 'field_account',
                  'table' => 'event_enrollment__field_account',
                  'field' => 'field_account',
                  'relationship' => 'none',
                  'group_type' => 'group',
                  'admin_label' => 'field_account: User',
                  'required' => FALSE,
                  'plugin_id' => 'standard',
                ],
                'profile' => [
                  'id' => 'profile',
                  'table' => 'users_field_data',
                  'field' => 'profile',
                  'relationship' => 'field_account',
                  'group_type' => 'group',
                  'admin_label' => 'Profile',
                  'required' => FALSE,
                  'entity_type' => 'user',
                  'plugin_id' => 'standard',
                ],
              ],
              'arguments' => [
                'nid' => [
                  'id' => 'nid',
                  'table' => 'node_field_data',
                  'field' => 'nid',
                  'relationship' => 'field_event',
                  'group_type' => 'group',
                  'admin_label' => '',
                  'default_action' => 'empty',
                  'exception' => [
                    'value' => 'all',
                    'title_enable' => FALSE,
                    'title' => t('All'),
                  ],
                  'title_enable' => FALSE,
                  'title' => '',
                  'default_argument_type' => 'fixed',
                  'default_argument_options' => [
                    'argument' => '',
                  ],
                  'default_argument_skip_url' => FALSE,
                  'summary_options' => [
                    'base_path' => '',
                    'count' => TRUE,
                    'items_per_page' => 25,
                    'override' => FALSE,
                  ],
                  'summary' => [
                    'sort_order' => 'asc',
                    'number_of_records' => 0,
                    'format' => 'default_summary',
                  ],
                  'specify_validation' => FALSE,
                  'validate' => [
                    'type' => 'none',
                    'fail' => 'not found',
                  ],
                  'validate_options' => [],
                  'break_phrase' => FALSE,
                  'not' => FALSE,
                  'entity_type' => 'node',
                  'entity_field' => 'nid',
                  'plugin_id' => 'node_nid',
                ],
              ],
              'display_extenders' => [],
            ],
            'cache_metadata' => [
              'max-age' => -1,
              'contexts' => [
                'languages:language_content',
                'languages:language_interface',
                'url',
                'url.query_args',
              ],
              'tags' => [
                'config:core.entity_view_display.profile.profile.autocomplete_item',
                'config:core.entity_view_display.profile.profile.compact',
                'config:core.entity_view_display.profile.profile.compact_notification',
                'config:core.entity_view_display.profile.profile.compact_teaser',
                'config:core.entity_view_display.profile.profile.default',
                'config:core.entity_view_display.profile.profile.hero',
                'config:core.entity_view_display.profile.profile.search_index',
                'config:core.entity_view_display.profile.profile.small',
                'config:core.entity_view_display.profile.profile.small_teaser',
                'config:core.entity_view_display.profile.profile.statistic',
                'config:core.entity_view_display.profile.profile.table',
                'config:core.entity_view_display.profile.profile.teaser',
                'config:field.storage.event_enrollment.field_request_message',
                'config:field.storage.event_enrollment.field_request_or_invite_status',
                'config:field.storage.profile.field_profile_organization',
              ],
            ],
          ],
          'page_manage_enrollment_requests' => [
            'display_plugin' => 'page',
            'id' => 'page_manage_enrollment_requests',
            'display_title' => 'Page',
            'position' => 1,
            'display_options' => [
              'display_extenders' => [],
              'path' => 'node/%node/all-enrollment-requests',
              'menu' => [
                'type' => 'none',
                'title' => t('Manage requests'),
                'description' => '',
                'expanded' => FALSE,
                'parent' => '',
                'weight' => 5,
                'context' => '0',
                'menu_name' => 'main',
              ],
            ],
            'cache_metadata' => [
              'max-age' => -1,
              'contexts' => [
                'languages:language_content',
                'languages:language_interface',
                'url',
                'url.query_args',
              ],
              'tags' => [
                'config:core.entity_view_display.profile.profile.autocomplete_item',
                'config:core.entity_view_display.profile.profile.compact',
                'config:core.entity_view_display.profile.profile.compact_notification',
                'config:core.entity_view_display.profile.profile.compact_teaser',
                'config:core.entity_view_display.profile.profile.default',
                'config:core.entity_view_display.profile.profile.hero',
                'config:core.entity_view_display.profile.profile.search_index',
                'config:core.entity_view_display.profile.profile.small',
                'config:core.entity_view_display.profile.profile.small_teaser',
                'config:core.entity_view_display.profile.profile.statistic',
                'config:core.entity_view_display.profile.profile.table',
                'config:core.entity_view_display.profile.profile.teaser',
                'config:field.storage.event_enrollment.field_request_message',
                'config:field.storage.event_enrollment.field_request_or_invite_status',
                'config:field.storage.profile.field_profile_organization',
              ],
            ],
          ],
        ],
      ],
      // Message templates.
      'message.template.request_event_enrollment' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'module' => [
            'activity_logger',
          ],
        ],
        'third_party_settings' => [
          'activity_logger' => [
            'activity_bundle_entities' => [
              'event_enrollment-event_enrollment' => 'event_enrollment-event_enrollment',
            ],
            'activity_action' => 'create_entitiy_action',
            'activity_context' => 'event_request_activity_context',
            'activity_destinations' => [
              'notifications' => 'notifications',
              'email' => 'email',
            ],
            'activity_create_direct' => FALSE,
            'activity_aggregate' => FALSE,
            'activity_entity_condition' => '',
          ],
        ],
        'template' => 'request_event_enrollment',
        'label' => t('Request event enrollment'),
        'description' => 'A user request an enrollment for event',
        'text' => [
          [
            'value' => '<p><a href="[social_event:enrolled_event_url]">[social_event:enrolled_user]</a> has requested enrollment to the event [social_event:event_iam_organizing] you are organizing</p>',
            'format' => 'full_html',
          ],
          [
            'value' => '<p><a href="[social_event:enrolled_event_url]">[social_event:enrolled_user]</a> has requested enrollment to the event [social_event:event_iam_organizing] you are organizing</p>',
            'format' => 'full_html',
          ],
          [
            'value' => '<p><a href="[social_event:enrolled_event_url]">[social_event:enrolled_user]</a> has requested enrollment to the event [social_event:event_iam_organizing] you are organizing</p>',
            'format' => 'full_html',
          ],
        ],
        'settings' => [
          'token options' => [
            'clear' => FALSE,
            'token replace' => TRUE,
          ],
          'purge_override' => FALSE,
          'purge_methods' => [],
        ],
      ],
      'message.template.event_request_approved' => [
        'langcode' => 'en',
        'status' => TRUE,
        'dependencies' => [
          'module' => [
            'activity_logger',
          ],
        ],
        'third_party_settings' => [
          'activity_logger' => [
            'activity_bundle_entities' => [
              'event_enrollment-event_enrollment' => 'event_enrollment-event_enrollment',
            ],
            'activity_action' => 'update_entity_action',
            'activity_context' => 'event_request_activity_context',
            'activity_destinations' => [
              'notifications' => 'notifications',
              'email' => 'email',
            ],
            'activity_create_direct' => TRUE,
            'activity_aggregate' => FALSE,
            'activity_entity_condition' => '',
          ],
        ],
        'template' => 'event_request_approved',
        'label' => t('Request approved event enrollment'),
        'description' => 'The request to enroll to an enrollment is approved',
        'text' => [
          [
            'value' => '<p><a href="[message:author:url:absolute]">[message:author:display-name]</a> approved your request to enroll for the event [social_event:event_iam_organizing]</p>',
            'format' => 'full_html',
          ],
          [
            'value' => '<p><a href="[message:author:url:absolute]">[message:author:display-name]</a> approved your request to enroll for the event [social_event:event_iam_organizing]</p>',
            'format' => 'full_html',
          ],
          [
            'value' => '<p><a href="[message:author:url:absolute]">[message:author:display-name]</a> approved your request to enroll for the event [social_event:event_iam_organizing]</p>',
            'format' => 'full_html',
          ],
        ],
        'settings' => [
          'token options' => [
            'clear' => FALSE,
            'token replace' => TRUE,
          ],
          'purge_override' => FALSE,
          'purge_methods' => [],
        ],
      ],
    ];

    // Count the amount we need to add to cover batching..
    $sandbox['total'] = count($sandbox['configs']);
    $sandbox['current'] = 0;
  }

  $names = array_keys($sandbox['configs']);
  $name = (string) $names[$sandbox['current']++];
  $data = $sandbox['configs'][$name];

  $parts = explode('.', $name);

  switch ($parts[0] . '.' . $parts[1]) {
    case 'field.storage':
      $entity_type = \Drupal::service('config.manager')->getEntityTypeIdByName($name);

      /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
      $storage = \Drupal::entityTypeManager()->getStorage($entity_type);
      $entity = $storage->createFromStorageRecord($data);
      $entity->save();
      break;

    case 'field.field':
      $field_config = FieldConfig::loadByName($parts[2], $parts[3], $parts[4]);

      if ($field_config instanceof FieldConfigInterface) {
        $field_config->setDescription($data);
      }
      else {
        $field_config = FieldConfig::create($data);
      }

      $field_config->save();
      break;

    default:
      // Insert newly created config in the storage.
      \Drupal::service('config.storage')->write($name, $data);
  }

  $sandbox['#finished'] = $sandbox['current'] / $sandbox['total'];
}

/**
 * Node event and views changes for the social_event request enrollment feature.
 */
function social_event_update_8806() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8806');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Grant CM+ with 'manage event enrollment requests' permission.
 */
function social_event_update_8807() {
  $roles = Role::loadMultiple();
  /** @var \Drupal\user\Entity\Role $role */
  foreach ($roles as $role) {
    if ($role->id() === 'contentmanager' || $role->id() === 'sitemanager') {
      user_role_grant_permissions($role->id(), ['manage event enrollment requests']);
    }
  }
}

/**
 * Add new field for rendered profile entity so we can sort it.
 *
 * Load in a config file from an specific update hook that will never change.
 * Update helper did not update all fields correctly.
 */
function social_event_update_8808() {
  $config_file = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/update/social_event_update_8808.yml';

  if (is_file($config_file)) {
    $settings = Yaml::parse(file_get_contents($config_file));
    if (is_array($settings)) {
      $config = \Drupal::configFactory()
        ->getEditable('views.view.event_manage_enrollment_requests');
      $config->setData($settings)->save(TRUE);
    }
  }
}

/**
 * Update the enrollment method text of an event on event add form.
 *
 * Load in a config file from an specific update hook that will never change.
 * Update helper did not update all fields correctly.
 */
function social_event_update_8809() {
  $config_file = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/update/social_event_update_8809.yml';

  if (is_file($config_file)) {
    $settings = Yaml::parse(file_get_contents($config_file));
    if (is_array($settings)) {
      $config = \Drupal::configFactory()
        ->getEditable('field.storage.node.field_enroll_method');
      $config->setData($settings)->save(TRUE);
    }
  }
}

/**
 * Adds the enrollment method field as filter on the community events page.
 */
function social_event_update_8810() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8810');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Install Event Invite module by default.
 */
function social_event_update_8901() {
  $modules = ['social_event_invite'];
  \Drupal::service('module_installer')->install($modules);
}

/**
 * Add a new block to display notifications for event requests.
 *
 * Load in a config file from an specific update hook that will never change.
 */
function social_event_update_8902() {
  $config_files = [
    'block.block.eventrequestsnotification' => \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static/block.block.eventrequestsnotification_8901.yml',
    'block.block.eventrequestsnotification_2' => \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static/block.block.eventrequestsnotification_2_8901.yml',
  ];

  foreach ($config_files as $key => $config_file) {
    if (is_file($config_file)) {
      $settings = Yaml::parse(file_get_contents($config_file));
      if (is_array($settings)) {
        $config = \Drupal::configFactory()
          ->getEditable($key);
        $config->setData($settings)->save(TRUE);
      }
    }
  }
}

/**
 * Update community events views.
 */
function social_event_update_8903() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8903');

  // Update views configuration.
  _social_event_views_update('views.view.upcoming_events', 'page_community_events');
}

/**
 * Update user's events views.
 */
function social_event_update_8904() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8904');

  // Update views configuration.
  _social_event_views_update('views.view.events', 'events_overview');
}

/**
 * Install Event Add To Calendar module.
 */
function social_event_update_8905() {
  \Drupal::service('module_installer')->install(['social_event_addtocal']);
}

/**
 * Empty, moved to social_event_update_8915().
 */
function social_event_update_8906() {
  // Code has been moved to social_event_update_8915().
}

/**
 * Add image file extensions to be added as attachments.
 */
function social_event_update_8907() {
  $config_file = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static/field.field.node.event.field_files_8907.yml';

  if (is_file($config_file)) {
    $settings = Yaml::parse(file_get_contents($config_file));
    if (is_array($settings)) {
      $config = \Drupal::configFactory()
        ->getEditable('field.field.node.event.field_files');

      $config->setData($settings)->save(TRUE);
    }
  }
}

/**
 * Update labels for content visibility.
 */
function social_event_update_8908() {
  // Load the existing configuration.
  $config_name = 'field.storage.node.field_content_visibility';
  $config = \Drupal::configFactory()->getEditable($config_name);
  $config_data = $config->getRawData();

  if (!empty($config_data['settings']['allowed_values'])) {
    foreach ($config_data['settings']['allowed_values'] as $key => $value) {
      if (!empty($value['label'])) {
        // Since we are not sure about the array keys for the allowed values
        // we loop over them, and whenever there is a possible label match
        // we alter it.
        // This to ensure any custom added values are not affected.
        if (strpos($value['label'], 'Public -') !== FALSE) {
          $config_data['settings']['allowed_values'][$key]['label'] = 'Public';
        }
        if (strpos($value['label'], 'Community -') !== FALSE) {
          $config_data['settings']['allowed_values'][$key]['label'] = 'Community';
        }
        if (strpos($value['label'], 'Group members -') !== FALSE) {
          $config_data['settings']['allowed_values'][$key]['label'] = 'Group members';
        }
      }
    }

    $config->setData($config_data)->save();
    // Make sure we clear cached definitions for the fields.
    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
  }
}

/**
 * Updated field_enroll_method field label.
 */
function social_event_update_8909() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8909');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update the enrollment method text of an event on event add form.
 */
function social_event_update_8910() {
  // Load the existing configuration.
  $config_name = 'field.storage.node.field_enroll_method';
  $config = \Drupal::configFactory()->getEditable($config_name);
  $config_data = $config->getRawData();

  if (!empty($config_data['settings']['allowed_values'])) {
    foreach ($config_data['settings']['allowed_values'] as $key => $value) {
      if (!empty($value['label'])) {
        // Since we are not sure about the array keys for the allowed values
        // we loop over them, and whenever there is a possible label match
        // we alter it.
        // This to ensure any custom added values are not affected.
        if (strpos($value['label'], 'Open') !== FALSE) {
          $config_data['settings']['allowed_values'][$key]['label'] = 'Open to enroll';
        }
        if (strpos($value['label'], 'Request') !== FALSE) {
          $config_data['settings']['allowed_values'][$key]['label'] = 'Request to enroll';
        }
        if (strpos($value['label'], 'Invite-only') !== FALSE) {
          $config_data['settings']['allowed_values'][$key]['label'] = 'Invite-only';
        }
      }
    }

    $config->setData($config_data)->save();
    // Make sure we clear cached definitions for the fields.
    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
  }
}

/**
 * Updated fieldsets labels and added a new fieldset called "Settings".
 */
function social_event_update_8911() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8911');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Re-arranged fields in new fieldsets.
 */
function social_event_update_8912() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8912');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Remove un-required fieldgroup 'group_description' from event content type.
 */
function social_event_update_8914() {
  // There can be possibility that someone might have added fields in
  // fieldgroups we are removing. So, we want to skip removal if there are any
  // children present in fieldgroup.
  $field_groups = [
    'group_description',
  ];

  foreach ($field_groups as $field_group) {
    $group = field_group_load_field_group($field_group, 'node', 'event', 'form', 'default');
    if ($group && empty($group->children)) {
      field_group_delete_field_group($group);
    }
  }
}

/**
 * Show thumbnail on File fields when attachment is an image.
 */
function social_event_update_8915() {
  $config_file = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static/core.entity_view_display.node.event.default_8915.yml';

  if (is_file($config_file)) {
    $settings = Yaml::parse(file_get_contents($config_file));
    if (is_array($settings)) {
      $config = \Drupal::configFactory()
        ->getEditable('core.entity_view_display.node.event.default');

      $config->setData($settings)->save(TRUE);
    }
  }
}

/**
 * Add the 'enable event enrolment' field.
 */
function social_event_update_8916() {
  $config_path = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static';
  $source = new FileStorage($config_path);
  $entity_type_manager = \Drupal::entityTypeManager();

  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_storage_config_storage */
  $field_storage_config_storage = $entity_type_manager->getStorage('field_storage_config');

  // Create field storages.
  $field_type_manager = \Drupal::service('plugin.manager.field.field_type');
  $data = $source->read('field.storage.node.field_event_enable_enrollment_8916');
  $class = $field_type_manager->getPluginClass($data['type']);
  if (is_null($field_storage_config_storage->load($data['id']))) {
    $data['settings'] = $class::storageSettingsFromConfigData($data['settings']);
    $field_storage_config_storage->create($data)->save();
  }

  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_config_storage */
  $field_config_storage = $entity_type_manager->getStorage('field_config');
  // Create field settings.
  $data = $source->read('field.field.node.event.field_event_enable_enrollment_8916');
  if (is_null($field_config_storage->load($data['id']))) {
    $field_config_storage->create($data)->save();
  }
}

/**
 * Update event display.
 */
function social_event_update_8917() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8917');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Set default configs for event.
 */
function social_event_update_8918() {
  \Drupal::configFactory()->getEditable('social_event.settings')
    ->set('disable_event_enroll', FALSE)
    ->save();
}

/**
 * Add translation compatibility for Event fields and views.
 */
function social_event_update_8919() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_8919');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update event form labels.
 */
function social_event_update_10201() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_10201');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Allow CM+ translate "Event" node type.
 */
function social_event_update_10301() {
  foreach (['sitemanager', 'contentmanager'] as $role_id) {
    user_role_grant_permissions($role_id, ['translate event node']);
  }
}

/**
 * Update the configs in the database in accordance with the newest schema.
 */
function social_event_update_10302() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_10302');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update configuration for events views.
 */
function social_event_update_10303() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_10303');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Hide blocks on translations add/edit/delete pages.
 */
function social_event_update_10304() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Remove translation filter for the Event Enrollments view.
 */
function social_event_update_10305() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_10305');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update field_event_enroll as per value of field_event_enable_enrollment.
 */
function social_event_update_10306(&$sandbox) {
  /** @var \Drupal\node\NodeStorageInterface $node_storage */
  $node_storage = \Drupal::entityTypeManager()->getStorage('node');

  if (!isset($sandbox['total'])) {
    // Get all event ids.
    $query = $node_storage
      ->getQuery()
      ->accessCheck(FALSE)
      ->condition('type', 'event');

    $sandbox['ids'] = $query->execute();

    // Write total of entities need to be processed to $sandbox.
    $sandbox['total'] = $query->count()->execute();

    // Initiate default value for current processing № of element.
    $sandbox['current'] = 0;
    // Do not continue if no entities are found.
    if (empty($sandbox['total'])) {
      $sandbox['#finished'] = 1;
      return t('No events to be processed.');
    }
  }

  // Set the batch size equivalent to entity_update_batch_size defined.
  // @see: https://git.drupalcode.org/project/drupal/-/blob/9.2.16/sites/default/default.settings.php#L764
  $events_ids = array_slice($sandbox['ids'], $sandbox['current'], Settings::get('entity_update_batch_size') ?? 50);

  /** @var \Drupal\node\NodeInterface $event */
  foreach ($node_storage->loadMultiple($events_ids) as $event) {
    $sandbox['current']++;

    if (
      !$event->hasField('field_event_enable_enrollment') ||
      $event->get('field_event_enable_enrollment')->isEmpty()
    ) {
      continue;
    }

    if ($event->get('field_event_enable_enrollment')->first()->getValue()['value'] == '0') {
      $event->set('field_event_enroll', '0');
      $event->save();
    }

    \Drupal::messenger()
      ->addMessage($sandbox['current'] . ' users processed.');
  }

  // Try to update the percentage but avoid division by zero.
  $sandbox['#finished'] = empty($sandbox['total']) ? 1 : ($sandbox['current'] / $sandbox['total']);
}

/**
 * Delete not needed field "field_event_enable_enrollment".
 */
function social_event_update_10307() {
  $entity_type_manager = \Drupal::entityTypeManager();
  $entity_type = 'node';
  $bundle = 'event';
  $field_name = 'field_event_enable_enrollment';

  // Delete field config.
  /** @var \Drupal\field\FieldConfigStorage $field_config_storage */
  $field_config_storage = $entity_type_manager->getStorage('field_config');

  /** @var \Drupal\field\FieldConfigInterface|null $field */
  $field = $field_config_storage->load($entity_type . '.' . $bundle . '.' . $field_name);
  if (!is_null($field)) {
    $field->delete();
  }

  // Delete storage.
  /** @var \Drupal\field\FieldStorageConfigStorage $field_storage_storage */
  $field_storage_storage = $entity_type_manager->getStorage('field_storage_config');

  /** @var \Drupal\field\FieldStorageConfigInterface|null $field_storage */
  $field_storage = $field_storage_storage->load($entity_type . '.' . $field_name);
  if (!is_null($field_storage)) {
    $field_storage->delete();
  }
}

/**
 * Update event display.
 */
function social_event_update_10308() {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_10308');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update message template "message.template.activity_on_events_im_organizing".
 *
 * Added new 'preview' and 'cta_button' tokens.
 */
function social_event_update_10309() {
  $config_file = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static/message.template.activity_on_events_im_organizing_10309.yml';
  if (is_file($config_file)) {
    $settings = Yaml::parse(file_get_contents($config_file));
    if (is_array($settings)) {
      $config = \Drupal::configFactory()
        ->getEditable('message.template.activity_on_events_im_organizing');
      $config->setData($settings)->save(TRUE);
    }
  }
}

/**
 * Create a new 'All day' field for events.
 */
function social_event_update_10310(): void {
  $config_path = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static';
  $source = new FileStorage($config_path);
  $entity_type_manager = \Drupal::entityTypeManager();

  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_storage_config_storage */
  $field_storage_config_storage = $entity_type_manager->getStorage('field_storage_config');

  // Create field storages.
  /** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager */
  $field_type_manager = \Drupal::service('plugin.manager.field.field_type');
  $data = $source->read('field.storage.node.field_event_all_day_10310');
  if (is_array($data) && is_null($field_storage_config_storage->load($data['id']))) {
    $class = $field_type_manager->getPluginClass($data['type']);
    $data['settings'] = $class::storageSettingsFromConfigData($data['settings']);
    $field_storage_config_storage->create($data)->save();
  }

  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_config_storage */
  $field_config_storage = $entity_type_manager->getStorage('field_config');
  // Create field settings.
  $data = $source->read('field.field.node.event.field_event_all_day_10310');
  if (is_array($data) && is_null($field_config_storage->load($data['id']))) {
    $field_config_storage->create($data)->save();
  }
}

/**
 * Update event display.
 */
function social_event_update_10311(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', 'social_event_update_10311');

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Add new field to Event node type; Add new message template.
 */
function social_event_update_11401(): void {
  try {
    $content = file_get_contents(\Drupal::service('extension.list.module')->getPath('social_event') . '/config/static/core.entity_view_display.node.event.email_card_11401.yml');
    if (is_string($content)) {
      $yml = Yaml::parse($content);
      EntityViewDisplay::create($yml)->save();
    }

    // Prepare the path.
    $path = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static/message.template.user_was_enrolled_to_event_11401.yml';

    // Retrieves the configuration factory.
    $config_factory = \Drupal::configFactory();

    // Create new message template.
    if (is_file($path)) {
      $file_content = file_get_contents($path);
      $settings = Yaml::parse($file_content === FALSE ? '' : $file_content);
      if (is_array($settings)) {
        $config = $config_factory->getEditable('message.template.user_was_enrolled_to_event');
        $config->setData($settings)->save(TRUE);
      }
    }

    $source = new FileStorage(\Drupal::service('extension.list.module')->getPath('social_event') . '/config/static');

    // Create a new field from the yaml configuration and save.
    \Drupal::entityTypeManager()->getStorage('field_storage_config')
      ->create((array) $source->read('field.storage.node.field_event_send_confirmation_11401'))
      ->save();

    // Create a new field instance from the yaml configuration and save.
    \Drupal::entityTypeManager()->getStorage('field_config')
      ->create((array) $source->read('field.field.node.event.field_event_send_confirmation_11401'))
      ->save();

  }
  catch (EntityStorageException $e) {
    \Drupal::logger('social_event')->error($e->getMessage());
  }
}

/**
 * Update event display.
 */
function social_event_update_11402(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update exposed filter button name.
 */
function social_event_update_11403(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Add new "Hide enrollments" field to Event node type.
 */
function social_event_update_11501(): void {
  $config_path = \Drupal::service('extension.list.module')->getPath('social_event') . '/config/static';
  $source = new FileStorage($config_path);

  // Create a new field from the yaml configuration and save.
  \Drupal::entityTypeManager()->getStorage('field_storage_config')
    ->create((array) $source->read('field.storage.node.field_hide_enrollments_11501'))
    ->save();

  // Create a new field instance from the yaml configuration and save.
  \Drupal::entityTypeManager()->getStorage('field_config')
    ->create((array) $source->read('field.field.node.event.field_hide_enrollments_11501'))
    ->save();
}

/**
 * Update event default form display.
 */
function social_event_update_11502(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Update the message template for user enrolling to an event.
 */
function social_event_update_11901(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Fix email sending when user enrolling to an event.
 */
function social_event_update_11902(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Fix configs that don't have UUIDs.
 */
function social_event_update_11903(): void {
  try {
    /** @var \Drupal\Core\Entity\EntityInterface $email_card_view_display */
    $email_card_view_display = EntityViewDisplay::load('node.event.email_card');
    if ($email_card_view_display->uuid() === NULL || empty($email_card_view_display->uuid())) {
      $site = \Drupal::configFactory()
        ->getEditable('core.entity_view_display.node.event.email_card');
      $site->set('uuid', \Drupal::service('uuid')->generate());
      $site->save(TRUE);
    }

    /** @var \Drupal\Core\Entity\EntityInterface $email_card_view_mode */
    $email_card_view_mode = EntityViewMode::load('node.email_card');
    if ($email_card_view_mode->uuid() === NULL || empty($email_card_view_mode->uuid())) {
      $site = \Drupal::configFactory()
        ->getEditable('core.entity_view_mode.node.email_card');
      $site->set('uuid', \Drupal::service('uuid')->generate());
      $site->save(TRUE);
    }

    // List of broken or NULL UUIDs.
    $config_list = [
      'message.template.user_was_enrolled_to_event',
      'views.view.event_manage_enrollments',
      'views.view.group_manage_members',
      'views.view.user_admin_people',
    ];

    foreach ($config_list as $config_name) {
      /** @var \Drupal\Core\Config\Config $config */
      $config = \Drupal::service('config.factory')->getEditable($config_name);
      $config->set('uuid', \Drupal::service('uuid')->generate());
      $config->save();
    }
  }
  catch (ConfigException $e) {
    \Drupal::logger('social_event')->error($e->getMessage());
  }
}

/**
 * Update the views that are associated with enrolling in an event.
 *
 * To prevent duplication of users.
 */
function social_event_update_11904(): void {
  $configs = [
    'event_enrollments',
    'event_manage_enrollments',
    'manage_enrollments',
    'event_manage_enrollment_invites',
    'event_manage_enrollment_requests',
    'managers',
  ];

  // Updating views that are responsible for receiving users,
  // who have enrolled for an event or are the organisers of this event.
  foreach ($configs as $config_name) {
    $config_value = \Drupal::configFactory()->getEditable('views.view.' . $config_name);
    if ($config_value !== NULL) {
      $data = $config_value->getRawData();
      if (isset($data['display']['default']['display_options']['query']['options']['distinct'])) {
        $data['display']['default']['display_options']['query']['options']['distinct'] = TRUE;
        $config_value->setData($data)->save();
      }
    }
  }
}

/**
 * Remove deprecated permission "override event revision log entry".
 */
function social_event_update_111101(): void {
  $entity_type_manager = \Drupal::entityTypeManager();
  /** @var \Drupal\user\RoleInterface[] $roles */
  $roles = $entity_type_manager->getStorage('user_role')->loadMultiple();

  $deprecated_permissions = [
    'override event revision log entry',
  ];

  foreach ($deprecated_permissions as $deprecated_permission) {
    foreach ($roles as $role) {
      if ($role->hasPermission($deprecated_permission)) {
        $role->revokePermission($deprecated_permission);
        $role->save();
      }
    }
  }
}

/**
 * Search for invalid permission(s) and remove them from existing roles.
 *
 * Permissions to check:
 * - "translate event node".
 */
function social_event_update_111102(): void {
  $entity_type_manager = \Drupal::entityTypeManager();
  $all_permissions = array_keys(\Drupal::service('user.permissions')->getPermissions());
  /** @var \Drupal\user\RoleInterface[] $roles */
  $roles = $entity_type_manager->getStorage('user_role')->loadMultiple();

  $permissions_to_check = [
    'translate event node',
  ];

  // If permission is not valid (is not on the list of all permissions),
  // we need to revoke it from all existing roles.
  foreach ($permissions_to_check as $permission_to_check) {
    if (!in_array($permission_to_check, $all_permissions)) {
      foreach ($roles as $role) {
        if ($role->hasPermission($permission_to_check)) {
          $role->revokePermission($permission_to_check);
          $role->save();
        }
      }
    }
  }
}

/**
 * Change the More Link from Event Enrollments view.
 */
function social_event_update_121001(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to a related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Change the event enrollments view header to a token.
 */
function social_event_update_121002(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Re-run: Change the More Link from Event Enrollments view.
 *
 * Due to an issue with expected config vs actual config
 * having translated strings in it.
 */
function social_event_update_121003(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to a related channel of update execution.
  return $updateHelper->logger()->output();
}

/**
 * Re-run: Change the event enrollments view header to a token.
 *
 * Due to an issue with expected config vs actual config
 * having translated strings in it.
 */
function social_event_update_121004(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_event', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}
