public function TopicContentBlock::query in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock::query()
- 10.3.x modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock::query()
- 10.0.x modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock::query()
- 10.1.x modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock::query()
- 10.2.x modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock::query()
Create filtering query.
Parameters
\Drupal\Core\Database\Query\SelectInterface $query: The query.
array $fields: The fields.
Overrides ContentBlockPluginInterface::query
File
- modules/
social_features/ social_content_block/ src/ Plugin/ ContentBlock/ TopicContentBlock.php, line 27
Class
- TopicContentBlock
- Provides a content block for topics.
Namespace
Drupal\social_content_block\Plugin\ContentBlockCode
public function query(SelectInterface $query, array $fields) {
foreach ($fields as $field_name => $entity_ids) {
switch ($field_name) {
// Add topic type tags.
case 'field_topic_type':
$query
->innerJoin('node__field_topic_type', 'tt', 'tt.entity_id = base_table.nid');
$query
->condition('tt.field_topic_type_target_id', $entity_ids, 'IN');
break;
// Add group tags.
case 'field_group':
$query
->innerJoin('group_content_field_data', 'gd', 'gd.entity_id = base_table.nid');
$query
->condition('gd.type', '%' . $query
->escapeLike('-group_node-topic'), 'LIKE');
$query
->condition('gd.gid', $entity_ids, 'IN');
break;
case 'field_content_tags':
$query
->innerJoin('node__social_tagging', 'st', 'st.entity_id = base_table.nid');
$query
->condition('st.social_tagging_target_id', $entity_ids, 'IN');
break;
}
}
}