public function SocialGroupAddForm::getGroupTypeElement in Open Social 8.3
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 8 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 8.2 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 8.4 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 8.5 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 8.6 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 8.7 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 8.8 modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 10.3.x modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 10.0.x modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 10.1.x modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
- 10.2.x modules/social_features/social_group/src/Form/SocialGroupAddForm.php \Drupal\social_group\Form\SocialGroupAddForm::getGroupTypeElement()
Get the group type element.
Note this element is also used in the edit group form.
Return value
array Returns an array containing the group type element and descriptions.
1 call to SocialGroupAddForm::getGroupTypeElement()
- SocialGroupAddForm::buildForm in modules/
social_features/ social_group/ src/ Form/ SocialGroupAddForm.php - Defines the settings form for Post entities.
File
- modules/
social_features/ social_group/ src/ Form/ SocialGroupAddForm.php, line 118
Class
- SocialGroupAddForm
- Class SocialGroupAddForm.
Namespace
Drupal\social_group\FormCode
public function getGroupTypeElement() {
$element = [
'#type' => 'radios',
'#title' => $this
->t('Group type'),
'#description' => $this
->t('Can not be changed once a group is created.'),
'#default_value' => 'open_group',
'#required' => TRUE,
'#cache' => [
'tags' => $this->entityTypeManager
->getDefinition('group_type')
->getListCacheTags(),
],
];
$group_types_options = [];
$group_types_descriptions = [];
$group_types = $this->entityTypeManager
->getStorage('group_type')
->loadMultiple();
/** @var \Drupal\group\Entity\GroupTypeInterface $group_type */
foreach ($group_types as $group_type) {
$access = $this->entityTypeManager
->getAccessControlHandler('group')
->createAccess($group_type
->id(), NULL, [], TRUE);
if ($access
->isAllowed()) {
$group_types_options[$group_type
->id()] = $group_type
->label();
$group_types_descriptions[$group_type
->id()] = [
'#description' => $group_type
->getDescription(),
];
}
$this->renderer
->addCacheableDependency($element, $access);
}
arsort($group_types_options);
$element['#options'] = $group_types_options;
return $element + $group_types_descriptions;
}