You are here

protected function GroupToGroupContent::getGroupContentTypeIds in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views/relationship/GroupToGroupContent.php \Drupal\group\Plugin\views\relationship\GroupToGroupContent::getGroupContentTypeIds()

Returns the group content types this relationship should filter on.

This checks if any plugins were selected on the option form and, in that case, loads only those group content types available to the selected plugins. Otherwise, all possible group content types for the relationship's entity type are loaded.

This needs to happen live to cover the use case where a group content plugin is installed on a group type after this relationship has been configured on a view without any plugins selected.

Return value

string[] The group content type IDs to filter on.

1 call to GroupToGroupContent::getGroupContentTypeIds()
GroupToGroupContent::query in src/Plugin/views/relationship/GroupToGroupContent.php
Add anything to the query that we might need to.

File

src/Plugin/views/relationship/GroupToGroupContent.php, line 174

Class

GroupToGroupContent
A relationship handler for group content.

Namespace

Drupal\group\Plugin\views\relationship

Code

protected function getGroupContentTypeIds() {

  // Even though the retrieval needs to happen live, there's nothing stopping
  // us from statically caching it during runtime.
  if (!isset($this->groupContentTypeIds)) {
    $plugin_ids = array_filter($this->options['group_content_plugins']);
    $group_content_type_ids = [];
    foreach ($plugin_ids as $plugin_id) {
      $group_content_type_ids = array_merge($group_content_type_ids, $this->pluginManager
        ->getGroupContentTypeIds($plugin_id));
    }
    $this->groupContentTypeIds = $plugin_ids ? $group_content_type_ids : array_keys(GroupContentType::loadMultiple());
  }
  return $this->groupContentTypeIds;
}