public function EditorSelector::getEditor in Drupal 10
Same name and namespace in other branches
- 8 core/modules/quickedit/src/EditorSelector.php \Drupal\quickedit\EditorSelector::getEditor()
- 9 core/modules/quickedit/src/EditorSelector.php \Drupal\quickedit\EditorSelector::getEditor()
File
- core/modules/quickedit/src/EditorSelector.php, line 52
Class
- EditorSelector
- Selects an in-place editor (an InPlaceEditor plugin) for a field.
Namespace
Drupal\quickedit
Code
public function getEditor($formatter_type, FieldItemListInterface $items) {
$formatter_info = $this->formatterManager
->getDefinition($formatter_type);
$editor_id = $formatter_info['quickedit']['editor'];
if ($editor_id === 'disabled') {
return;
}
elseif ($editor_id === 'form') {
return 'form';
}
$editor_choices = [
$editor_id,
];
if (isset($this->alternatives[$editor_id])) {
$editor_choices = array_merge($editor_choices, $this->alternatives[$editor_id]);
}
foreach ($editor_choices as $editor_id) {
$editor = $this->editorManager
->createInstance($editor_id);
if ($editor
->isCompatible($items)) {
return $editor_id;
}
}
return 'form';
}