function EntityLinkSuggestions::buildConfigurationForm
File
-
core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5Plugin/ EntityLinkSuggestions.php, line 63
Class
- EntityLinkSuggestions
- CKEditor 5 Entity Link Suggestions plugin.
Namespace
Drupal\ckeditor5\Plugin\CKEditor5PluginCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) : array {
$allowed_bundles = [];
$all_bundle_info = $this->entityTypeBundleInfo
->getAllBundleInfo();
foreach ($all_bundle_info as $entity_type => $bundles) {
foreach ($bundles as $key => $bundle) {
if (!empty($bundle['ckeditor5_link_suggestions'])) {
$allowed_bundles[$entity_type][$key] = $key;
}
}
}
$header = [
'enabled' => $this->t('Supported entity types'),
'bundles' => $this->t('Bundles'),
];
$form['entity_types'] = [
'#type' => 'table',
'#header' => $header,
'#title' => $this->t('Allowed entity types'),
];
$entity_types = $this->entityTypeManager
->getDefinitions();
foreach ($allowed_bundles as $entity_type_id => $bundles) {
$entity_type = $entity_types[$entity_type_id];
$bundles_for_entity_type = $this->entityTypeBundleInfo
->getBundleInfo($entity_type_id);
$bundles_list = [];
foreach ($bundles as $bundle) {
$bundles_list[] = $bundles_for_entity_type[$bundle]['label'];
}
$row = [
'enabled' => [
'#markup' => $entity_type->getCollectionLabel(),
],
'bundles' => [
[
'#markup' => $this->t('Included %bundles', [
'%bundles' => $this->entityTypeManager
->getDefinition($entity_type->getBundleEntityType())
->getPluralLabel(),
]),
],
[
'#theme' => 'item_list',
'#items' => $bundles_list,
'#list_type' => 'ol',
],
],
];
$form['entity_types'][$entity_type_id] = $row;
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.