protected function GroupMenuController::addPageBundles in Group Menu 8
Retrieves a list of available bundles for the add page.
Parameters
\Drupal\group\Entity\GroupInterface $group: The group to add the group content to.
bool $create_mode: Whether the target entity still needs to be created.
Return value
array An array of group content type IDs, keyed by the plugin that was used to generate their respective group content types.
Overrides GroupContentController::addPageBundles
See also
::addPage()
1 call to GroupMenuController::addPageBundles()
- GroupMenuController::addPage in src/
Controller/ GroupMenuController.php - Provides the group content creation overview page.
File
- src/
Controller/ GroupMenuController.php, line 112
Class
- GroupMenuController
- Returns responses for 'group_menu' GroupContent routes.
Namespace
Drupal\groupmenu\ControllerCode
protected function addPageBundles(GroupInterface $group, $create_mode) {
$bundles = [];
// Retrieve all group_node plugins for the group's type.
$plugin_ids = $this->pluginManager
->getInstalledIds($group
->getGroupType());
foreach ($plugin_ids as $key => $plugin_id) {
if (strpos($plugin_id, 'group_menu:') !== 0) {
unset($plugin_ids[$key]);
}
}
// Retrieve all of the responsible group content types, keyed by plugin ID.
$storage = $this->entityTypeManager
->getStorage('group_content_type');
$properties = [
'group_type' => $group
->bundle(),
'content_plugin' => $plugin_ids,
];
foreach ($storage
->loadByProperties($properties) as $bundle => $group_content_type) {
/** @var \Drupal\group\Entity\GroupContentTypeInterface $group_content_type */
$bundles[$group_content_type
->getContentPluginId()] = $bundle;
}
return $bundles;
}