protected function EntityDisplayBulkCloneForm::getDisplayOptions in Field tools 8
Get the form options for a display type.
Parameters
$type: The entity type ID of the display type.
$entity_type_id: The target entity type ID of the displays.
$bundle: The target bundle.
Return value
An array of form options.
1 call to EntityDisplayBulkCloneForm::getDisplayOptions()
- EntityDisplayBulkCloneForm::buildForm in src/
Form/ EntityDisplayBulkCloneForm.php - Form constructor.
File
- src/
Form/ EntityDisplayBulkCloneForm.php, line 144
Class
- EntityDisplayBulkCloneForm
- Provides a form to clone displays from an entity bundle.
Namespace
Drupal\field_tools\FormCode
protected function getDisplayOptions($type, $entity_type_id, $bundle) {
$display_ids = $this->entityTypeManager
->getStorage($type)
->getQuery()
->condition('targetEntityType', $entity_type_id)
->condition('bundle', $bundle)
->execute();
$form_displays = $this->entityTypeManager
->getStorage($type)
->loadMultiple($display_ids);
// Unfortunately, getDisplayModesByEntityType() is protected :(
if ($type == 'entity_form_display') {
$mode_options = $this->entityDisplayRepository
->getFormModeOptions($entity_type_id);
}
else {
$mode_options = $this->entityDisplayRepository
->getViewModeOptions($entity_type_id);
}
$form_display_options = [];
foreach ($form_displays as $id => $form_display) {
// The label() method of displays returns NULL always, so we get the label
// from the related mode.
$form_display_options[$id] = $mode_options[$form_display
->getMode()];
}
asort($form_display_options);
return $form_display_options;
}