You are here

function social_event_content_block_update_8002 in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_content_block/modules/social_event_content_block/social_event_content_block.install \social_event_content_block_update_8002()
  2. 8.8 modules/social_features/social_content_block/modules/social_event_content_block/social_event_content_block.install \social_event_content_block_update_8002()
  3. 10.3.x modules/social_features/social_content_block/modules/social_event_content_block/social_event_content_block.install \social_event_content_block_update_8002()
  4. 10.0.x modules/social_features/social_content_block/modules/social_event_content_block/social_event_content_block.install \social_event_content_block_update_8002()
  5. 10.2.x modules/social_features/social_content_block/modules/social_event_content_block/social_event_content_block.install \social_event_content_block_update_8002()

Add field event date filter to event content list blocks.

File

modules/social_features/social_content_block/modules/social_event_content_block/social_event_content_block.install, line 25
Installation code for the social_event_content_block module.

Code

function social_event_content_block_update_8002() {
  $configs = [
    'field_storage_config' => [
      'langcode' => 'en',
      'status' => TRUE,
      'dependencies' => [
        'module' => [
          'block_content',
          'options',
        ],
      ],
      'id' => 'block_content.field_event_date',
      'field_name' => 'field_event_date',
      'entity_type' => 'block_content',
      'type' => 'list_string',
      'settings' => [
        'allowed_values' => [
          [
            'value' => 'future',
            'label' => 'Future Events',
          ],
          [
            'value' => 'past',
            'label' => 'Past Events',
          ],
          [
            'value' => 'last_month',
            'label' => 'Last Month',
          ],
          [
            'value' => 'current_month',
            'label' => 'This month',
          ],
          [
            'value' => 'next_month',
            'label' => 'Next month',
          ],
          [
            'value' => 'ongoing',
            'label' => 'Ongoing',
          ],
          [
            'value' => 'last_30',
            'label' => 'Last 30 days',
          ],
          [
            'value' => 'next_30',
            'label' => 'Next 30 days',
          ],
          [
            'value' => 'last_14',
            'label' => 'Last 14 days',
          ],
          [
            'value' => 'next_14',
            'label' => 'Next 14 days',
          ],
          [
            'value' => 'last_7',
            'label' => 'Last 7 days',
          ],
          [
            'value' => 'next_7',
            'label' => 'Next 7 days',
          ],
        ],
        'allowed_values_function' => '',
      ],
      'module' => 'options',
      'locked' => FALSE,
      'cardinality' => 1,
      'translatable' => TRUE,
      'indexes' => [],
      'persist_with_no_fields' => FALSE,
      'custom_storage' => FALSE,
    ],
    'field_config' => [
      'langcode' => 'en',
      'status' => TRUE,
      'dependencies' => [
        'config' => [
          'block_content.type.custom_content_list',
          'field.storage.block_content.field_event_date',
        ],
        'module' => [
          'options',
        ],
      ],
      'id' => 'block_content.custom_content_list.field_event_date',
      'field_name' => 'field_event_date',
      'entity_type' => 'block_content',
      'bundle' => 'custom_content_list',
      'label' => 'Date period',
      'description' => '',
      'required' => FALSE,
      'translatable' => FALSE,
      'default_value' => [
        [
          'value' => 'future',
        ],
      ],
      'default_value_callback' => '',
      'settings' => [],
      'field_type' => 'list_string',
    ],
  ];
  foreach ($configs as $entity_type_id => $data) {

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