function social_topic_update_8908 in Open Social 10.0.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_topic/social_topic.install \social_topic_update_8908()
 - 10.1.x modules/social_features/social_topic/social_topic.install \social_topic_update_8908()
 - 10.2.x modules/social_features/social_topic/social_topic.install \social_topic_update_8908()
 
Add icons to default topic types.
File
- modules/
social_features/ social_topic/ social_topic.install, line 358  - Install, update and uninstall functions for the social_topic module.
 
Code
function social_topic_update_8908() {
  // Default topic types.
  $topic_types = [
    [
      'label' => t('Blog')
        ->render(),
      'icon' => 'icon-blog',
    ],
    [
      'label' => t('Discussion')
        ->render(),
      'icon' => 'icon-discussion',
    ],
    [
      'label' => t('News')
        ->render(),
      'icon' => 'icon-news',
    ],
  ];
  foreach ($topic_types as $type) {
    $term = _social_topic_get_term_id_by_name($type['label']);
    if ($term && $term
      ->hasField('field_topic_type_icon') && $term->field_topic_type_icon
      ->isEmpty()) {
      $term->field_topic_type_icon->value = $type['icon'];
      $term
        ->save();
    }
  }
}