function ContentModerationConfigureEntityTypesForm::ajaxCallback
Same name in other branches
- 8.9.x core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php \Drupal\content_moderation\Form\ContentModerationConfigureEntityTypesForm::ajaxCallback()
- 10 core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php \Drupal\content_moderation\Form\ContentModerationConfigureEntityTypesForm::ajaxCallback()
- 11.x core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php \Drupal\content_moderation\Form\ContentModerationConfigureEntityTypesForm::ajaxCallback()
Ajax callback to close the modal and update the selected text.
Return value
\Drupal\Core\Ajax\AjaxResponse An ajax response object.
File
-
core/
modules/ content_moderation/ src/ Form/ ContentModerationConfigureEntityTypesForm.php, line 199
Class
- ContentModerationConfigureEntityTypesForm
- The form for editing entity types associated with a workflow.
Namespace
Drupal\content_moderation\FormCode
public function ajaxCallback() {
$selected_bundles = [];
foreach ($this->bundleInfo
->getBundleInfo($this->entityType
->id()) as $bundle_id => $bundle) {
if ($this->workflow
->getTypePlugin()
->appliesToEntityTypeAndBundle($this->entityType
->id(), $bundle_id)) {
$selected_bundles[$bundle_id] = $bundle['label'];
}
}
$selected_bundles_list = [
'#theme' => 'item_list',
'#items' => $selected_bundles,
'#context' => [
'list_style' => 'comma-list',
],
'#empty' => $this->t('none'),
];
$response = new AjaxResponse();
$response->addCommand(new CloseDialogCommand());
$response->addCommand(new HtmlCommand('#selected-' . $this->entityType
->id(), $selected_bundles_list));
return $response;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.