You are here

protected function GroupContentEnablerManager::getGroupTypeInstalled in Group 8

Retrieves fully instantiated plugins for a group type.

Parameters

\Drupal\group\Entity\GroupTypeInterface $group_type: The group type to instantiate the installed plugins for.

Return value

\Drupal\group\Plugin\GroupContentEnablerCollection A plugin collection with fully instantiated plugins for the group type.

1 call to GroupContentEnablerManager::getGroupTypeInstalled()
GroupContentEnablerManager::getInstalled in src/Plugin/GroupContentEnablerManager.php
Returns a plugin collection of all installed content enablers.

File

src/Plugin/GroupContentEnablerManager.php, line 263

Class

GroupContentEnablerManager
Manages GroupContentEnabler plugin implementations.

Namespace

Drupal\group\Plugin

Code

protected function getGroupTypeInstalled(GroupTypeInterface $group_type) {
  if (!isset($this->groupTypeInstalled[$group_type
    ->id()])) {
    $configurations = [];
    $group_content_types = $this
      ->getGroupContentTypeStorage()
      ->loadByGroupType($group_type);

    // Get the plugin config from every group content type for the group type.
    foreach ($group_content_types as $group_content_type) {
      $plugin_id = $group_content_type
        ->getContentPluginId();

      // Grab the plugin config from every group content type and amend it
      // with the group type ID so the plugin knows what group type to use. We
      // also specify the 'id' key because DefaultLazyPluginCollection throws
      // an exception if it is not present.
      $configuration = $group_content_type
        ->get('plugin_config');
      $configuration['group_type_id'] = $group_type
        ->id();
      $configuration['id'] = $plugin_id;
      $configurations[$plugin_id] = $configuration;
    }
    $plugins = new GroupContentEnablerCollection($this, $configurations);
    $plugins
      ->sort();
    $this->groupTypeInstalled[$group_type
      ->id()] = $plugins;
  }
  return $this->groupTypeInstalled[$group_type
    ->id()];
}