You are here

social_event.install in Open Social 10.3.x

Install, update and uninstall functions for the social_event module.

File

modules/social_features/social_event/social_event.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the social_event module.
 */
use Drupal\Core\Config\FileStorage;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldConfigInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\user\Entity\Role;
use Symfony\Component\Yaml\Yaml;

/**
 * Implements hook_install().
 *
 * Perform actions related to the installation of social_event.
 */
function social_event_install() {

  // Set some default permissions.
  _social_event_set_permissions();

  // Add menu links.
  _social_event_create_menu_links();
}

/**
 * Function to set permissions.
 */
function _social_event_set_permissions() {
  $roles = Role::loadMultiple();

  /** @var \Drupal\user\Entity\Role $role */
  foreach ($roles as $role) {
    if ($role
      ->id() === 'administrator') {
      continue;
    }
    $permissions = _social_event_get_permissions($role
      ->id());
    user_role_grant_permissions($role
      ->id(), $permissions);
  }
}

/**
 * Build permissions.
 *
 * @param string $role
 *   The role.
 *
 * @return array
 *   Returns an array containing the permissions.
 */
function _social_event_get_permissions($role) {

  // Anonymous.
  $permissions['anonymous'] = [
    'view node.event.field_content_visibility:public content',
  ];

  // Authenticated.
  $permissions['authenticated'] = array_merge($permissions['anonymous'], [
    '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',
  ]);

  // Content manager.
  $permissions['contentmanager'] = array_merge($permissions['authenticated'], [
    'translate event node',
    'delete any event content',
    'edit any event content',
    'revert event revisions',
    'delete event revisions',
    'view event revisions',
    'override event revision log entry',
    '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',
  ]);

  // Site manager.
  $permissions['sitemanager'] = array_merge($permissions['contentmanager'], [
    'administer visibility settings',
    'administer social_event settings',
    'view published event enrollment entities',
  ]);
  if (isset($permissions[$role])) {
    return $permissions[$role];
  }
  return [];
}

/**
 * Function to create some menu items.
 */
function _social_event_create_menu_links() {
  $menu_links = MenuLinkContent::loadMultiple();
  $parent = NULL;

  /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */
  foreach ($menu_links as $menu_link) {
    if ($menu_link
      ->label() === 'Explore' && $menu_link
      ->isExpanded()) {
      $parent = 'menu_link_content:' . $menu_link
        ->uuid();
    }
  }
  if (!is_null($parent)) {
    MenuLinkContent::create([
      'title' => t('All events'),
      'link' => [
        'uri' => 'internal:/community-events',
      ],
      'menu_name' => 'main',
      'expanded' => FALSE,
      'weight' => 30,
      'parent' => $parent,
    ])
      ->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,
  ];
  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' => 'Pending',
            ],
            [
              'value' => 1,
              'label' => 'Approved',
            ],
            [
              'value' => 2,
              'label' => 'Declined',
            ],
            [
              'value' => 3,
              'label' => 'Invited',
            ],
            [
              'value' => 4,
              'label' => 'Pending reply',
            ],
            [
              'value' => 5,
              'label' => 'Accepted and joined',
            ],
            [
              'value' => 6,
              'label' => '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' => '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' => 'Open to enroll - users can enroll for this event without approval',
            ],
            1 => [
              'value' => 2,
              'label' => 'Request to enroll - users can "request to enroll" for this event which event organisers approve/decline',
            ],
            2 => [
              'value' => 3,
              'label' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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' => '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 = $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_get_path('module', '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_get_path('module', '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_get_path('module', 'social_event') . '/config/static/block.block.eventrequestsnotification_8901.yml',
    'block.block.eventrequestsnotification_2' => drupal_get_path('module', '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_get_path('module', '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_get_path('module', '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_get_path('module', '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();
}

Functions

Namesort descending Description
social_event_install Implements hook_install().
social_event_update_10201 Update event form labels.
social_event_update_10301 Allow CM+ translate "Event" node type.
social_event_update_10302 Update the configs in the database in accordance with the newest schema.
social_event_update_10303 Update configuration for events views.
social_event_update_10304 Hide blocks on translations add/edit/delete pages.
social_event_update_8001 Enable event enrolling of open groups for not member.
social_event_update_8002 Set permissions to administer social_event settings.
social_event_update_8003 Set my events permissions.
social_event_update_8801 Fix empty value in enroll setting.
social_event_update_8802 Remove public group from event.small_teaser.
social_event_update_8803 Update view mode for new small teaser style.
social_event_update_8804 Fix small teaser view mode after accidental regression for some sites.
social_event_update_8805 Install new fields for the request to join event.
social_event_update_8806 Node event and views changes for the social_event request enrollment feature.
social_event_update_8807 Grant CM+ with 'manage event enrollment requests' permission.
social_event_update_8808 Add new field for rendered profile entity so we can sort it.
social_event_update_8809 Update the enrollment method text of an event on event add form.
social_event_update_8810 Adds the enrollment method field as filter on the community events page.
social_event_update_8901 Install Event Invite module by default.
social_event_update_8902 Add a new block to display notifications for event requests.
social_event_update_8903 Update community events views.
social_event_update_8904 Update user's events views.
social_event_update_8905 Install Event Add To Calendar module.
social_event_update_8906 Empty, moved to social_event_update_8915().
social_event_update_8907 Add image file extensions to be added as attachments.
social_event_update_8908 Update labels for content visibility.
social_event_update_8909 Updated field_enroll_method field label.
social_event_update_8910 Update the enrollment method text of an event on event add form.
social_event_update_8911 Updated fieldsets labels and added a new fieldset called "Settings".
social_event_update_8912 Re-arranged fields in new fieldsets.
social_event_update_8914 Remove un-required fieldgroup 'group_description' from event content type.
social_event_update_8915 Show thumbnail on File fields when attachment is an image.
social_event_update_8916 Add the 'enable event enrolment' field.
social_event_update_8917 Update event display.
social_event_update_8918 Set default configs for event.
social_event_update_8919 Add translation compatibility for Event fields and views.
social_event_update_dependencies Implements hook_update_dependencies().
_social_event_create_menu_links Function to create some menu items.
_social_event_get_permissions Build permissions.
_social_event_set_permissions Function to set permissions.