social_content_block.api.php in Open Social 10.2.x
Same filename and directory in other branches
- 8.9 modules/social_features/social_content_block/social_content_block.api.php
- 8.6 modules/social_features/social_content_block/social_content_block.api.php
- 8.7 modules/social_features/social_content_block/social_content_block.api.php
- 8.8 modules/social_features/social_content_block/social_content_block.api.php
- 10.3.x modules/social_features/social_content_block/social_content_block.api.php
- 10.0.x modules/social_features/social_content_block/social_content_block.api.php
- 10.1.x modules/social_features/social_content_block/social_content_block.api.php
Hooks provided by the Social Content Block module.
File
modules/social_features/social_content_block/social_content_block.api.phpView source
<?php
/**
* @file
* Hooks provided by the Social Content Block module.
*/
use Drupal\Core\Database\Driver\mysql\Select;
use Drupal\block_content\BlockContentInterface;
/**
* Provide a method to alter the query to get content.
*
* @param \Drupal\Core\Database\Driver\mysql\Select $query
* Query to alter the results.
* @param \Drupal\block_content\BlockContentInterface $block_content
* Current block content.
*
* @ingroup social_content_block_api
*/
function hook_social_content_block_query_alter(Select $query, BlockContentInterface $block_content) {
// Get topic type tags.
$topic_types_list = $block_content
->get('field_topic_type')
->getValue();
$topic_types = array_map(function ($topic_type) {
return $topic_type['target_id'];
}, $topic_types_list);
// Add topic type tags.
if (!empty($topic_types)) {
$query
->innerJoin('node__field_topic_type', 'tt', 'tt.entity_id = n.nid');
$query
->condition('tt.field_topic_type_target_id', $topic_types, 'IN');
}
}
/**
* Alter the list of content block plugin definitions.
*
* @param array $info
* The content block plugin definitions to be altered.
*
* @see \Drupal\social_content_block\Annotation\ContentBlock
* @see \Drupal\social_content_block\ContentBlockManager
*/
function hook_social_content_block_info_alter(array &$info) {
if (isset($info['event_content_block'])) {
$info['event_content_block']['fields'][] = 'field_content_tags';
}
}
Functions
Name![]() |
Description |
---|---|
hook_social_content_block_info_alter | Alter the list of content block plugin definitions. |
hook_social_content_block_query_alter | Provide a method to alter the query to get content. |