You are here

class TopicContentBlock in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock
  2. 8.8 modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock
  3. 10.3.x modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock
  4. 10.0.x modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock
  5. 10.2.x modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php \Drupal\social_content_block\Plugin\ContentBlock\TopicContentBlock

Provides a content block for topics.

Plugin annotation


@ContentBlock(
  id = "topic_content_block",
  entityTypeId = "node",
  bundle = "topic",
  fields = {
    "field_topic_type",
    "field_content_tags",
    "field_group",
  },
)

Hierarchy

Expanded class hierarchy of TopicContentBlock

File

modules/social_features/social_content_block/src/Plugin/ContentBlock/TopicContentBlock.php, line 22

Namespace

Drupal\social_content_block\Plugin\ContentBlock
View source
class TopicContentBlock extends ContentBlockBase {

  /**
   * {@inheritdoc}
   */
  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;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentBlockBase::supportedSortOptions public function The sort options that are supported for this content block type. Overrides ContentBlockPluginInterface::supportedSortOptions 1
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 98
TopicContentBlock::query public function Create filtering query. Overrides ContentBlockPluginInterface::query