diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 0391b4510760e64ed1ab236ced22751ddd92fd92..1031c0a79053c4539e90bd2091c8880f4891a3fe 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -226,9 +226,16 @@ class UWService implements UWServiceInterface { case 'uw_ct_catalog_item': + $tags = [ + 'Category' => 'field_uw_catalog_category', + 'Faculty' => 'field_uw_catalog_faculty', + 'Audience' => 'field_uw_audience', + ]; + $content_data = [ 'title' => $get_title ? TRUE : NULL, 'content' => $get_content ? 'layout_builder__layout' : NULL, + 'catalog_tags' => $get_footer ? $tags : NULL, ]; break; @@ -330,8 +337,11 @@ class UWService implements UWServiceInterface { $node_data['date'] = $this->uwGetDates($node, $data); break; + case 'audience': + case 'category': + case 'faculty': case 'groups': - $node_data['groups'] = $this->uwGetTermsFromEntityField($node->$data, 'tags'); + $node_data[$index] = $this->uwGetTermsFromEntityField($node->$data, 'tags'); break; case 'image': @@ -362,12 +372,42 @@ class UWService implements UWServiceInterface { $node_data['hero'] = $this->uwGetSources($node, $data); break; + case 'catalog_tags': + + // Empty arrays so that we don't get undefined + // index errors. + $tabs = []; + $tags = []; + + // Get the entity and values for the catalog, + // which is the taxonomy term catalog. + $catalog_entity = $node->field_uw_catalog_catalog->entity; + $tabs_values = $catalog_entity->field_uw_catalog_tabs_display->getValue(); + + // Setup the array that we can use for in_array, + // which is the tabs to be displayed. + foreach ($tabs_values as $tab_value) { + $tabs[] = $tab_value['value']; + } + + // If there are tabs, then get them. + if (!empty($tabs)) { + foreach ($data as $key => $field) { + if (in_array($key, $tabs)) { + $tags[$key] = $this->uwGetTermsFromEntityField($node->$field, 'tags'); + } + } + } + + $node_data[$index] = $tags; + break; + case 'tags': $tags = []; foreach ($data as $field) { $tags = array_merge($tags, $this->uwGetTermsFromEntityField($node->$field, 'tags')); } - $node_data['tags'] = [$tags]; + $node_data[$index] = [$tags]; break; case 'title': @@ -419,6 +459,7 @@ class UWService implements UWServiceInterface { 'uw_ct_event', 'uw_ct_news_item', 'uw_ct_profile', + 'uw_ct_catalog_item', ]; break;