protected function OpignoModuleGroupController::addPageBundles in Opigno module 3.x
Same name and namespace in other branches
- 8 modules/opigno_module_group/src/Controller/OpignoModuleGroupController.php \Drupal\opigno_module_group\Controller\OpignoModuleGroupController::addPageBundles()
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 GroupNodeController::addPageBundles
See also
::addPage()
1 call to OpignoModuleGroupController::addPageBundles()
- OpignoModuleGroupController::addPage in modules/
opigno_module_group/ src/ Controller/ OpignoModuleGroupController.php - Provides the group content creation overview page.
File
- modules/
opigno_module_group/ src/ Controller/ OpignoModuleGroupController.php, line 92
Class
- OpignoModuleGroupController
- Returns responses for 'group_node' GroupContent routes.
Namespace
Drupal\opigno_module_group\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_node:') !== 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;
}