public function RecentGroupContentBlock::blockForm in Organic groups 8
Overrides BlockPluginTrait::blockForm
File
- src/
Plugin/ Block/ RecentGroupContentBlock.php, line 125
Class
- RecentGroupContentBlock
- Provides a block that shows recent group content for the current group.
Namespace
Drupal\og\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
$form['entity_type'] = [
'#type' => 'radios',
'#title' => $this
->t('Entity type'),
'#default_value' => $this->configuration['entity_type'],
'#description' => $this
->t('The entity type of the group content to show.'),
];
$entity_type_options = [];
foreach ($this->groupTypeManager
->getAllGroupContentBundleIds() as $entity_type_id => $bundle_ids) {
$entity_definition = $this->entityTypeManager
->getDefinition($entity_type_id);
$entity_type_options[$entity_type_id] = $entity_definition
->getLabel();
$bundle_options = [];
$bundle_info = $this->entityTypeBundleInfo
->getBundleInfo($entity_type_id);
foreach ($bundle_ids as $bundle_id) {
$bundle_options[$bundle_id] = $bundle_info[$bundle_id]['label'];
}
$form['bundles'][$entity_type_id] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Bundles'),
'#default_value' => $this->configuration['bundles'][$entity_type_id],
'#options' => $bundle_options,
'#description' => $this
->t('The group content bundles to show.'),
'#states' => [
'visible' => [
':input[name="settings[entity_type]"]' => [
'value' => $entity_type_id,
],
],
],
];
}
$form['entity_type']['#options'] = $entity_type_options;
$range = range(2, 20);
$form['count'] = [
'#type' => 'select',
'#title' => $this
->t('Number of results to show'),
'#default_value' => $this->configuration['count'],
'#options' => array_combine($range, $range),
];
return $form;
}