public static function FlexiformEntityFormDisplay::collectRenderDisplayLight in Flexiform 8
Collect the render display for a given entity_type_id and bundle.
Parameters
string $entity_type: The entity type id.
$bundle:
$form_mode:
Return value
\Drupal\Core\Entity\Display\EntityFormDisplayInterface
1 call to FlexiformEntityFormDisplay::collectRenderDisplayLight()
- EntityFormBlockDeriver::getDerivativeDefinitions in src/
Plugin/ Deriver/ EntityFormBlockDeriver.php - @todo: Contstrain contexts by bundle.
File
- src/
FlexiformEntityFormDisplay.php, line 79
Class
- FlexiformEntityFormDisplay
- Defines a class to extend EntityFormDisplays.
Namespace
Drupal\flexiformCode
public static function collectRenderDisplayLight($entity_type, $bundle, $form_mode) {
// Check the existence and status of:
// - the display for the form mode,
// - the 'default' display.
if ($form_mode != 'default') {
$candidate_ids[] = $entity_type . '.' . $bundle . '.' . $form_mode;
}
$candidate_ids[] = $entity_type . '.' . $bundle . '.default';
$results = \Drupal::entityQuery('entity_form_display')
->condition('id', $candidate_ids)
->condition('status', TRUE)
->execute();
// Load the first valid candidate display, if any.
$storage = \Drupal::entityManager()
->getStorage('entity_form_display');
foreach ($candidate_ids as $candidate_id) {
if (isset($results[$candidate_id])) {
$display = $storage
->load($candidate_id);
break;
}
}
// Else create a fresh runtime object.
if (empty($display)) {
$display = $storage
->create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $form_mode,
'status' => TRUE,
]);
}
// Let the display know which form mode was originally requested.
$display->originalMode = $form_mode;
// Let modules alter the display.
$display_context = [
'entity_type' => $entity_type,
'bundle' => $bundle,
'form_mode' => $form_mode,
];
\Drupal::moduleHandler()
->alter('entity_form_display', $display, $display_context);
return $display;
}