You are here

public function ExifSettingsController::entity_get_form_display in Exif 8.2

Same name and namespace in other branches
  1. 8 src/Controller/ExifSettingsController.php \Drupal\exif\Controller\ExifSettingsController::entity_get_form_display()

Implements hook_entity_get_form_display().

File

src/Controller/ExifSettingsController.php, line 580

Class

ExifSettingsController
Class ExifSettingsController manage action of settings pages.

Namespace

Drupal\exif\Controller

Code

public function entity_get_form_display($entity_type, $bundle, $form_mode) {

  // Try loading the entity from configuration.
  $entity_form_display = EntityFormDisplay::load($entity_type . '.' . $bundle . '.' . $form_mode);

  // If not found, create a fresh entity object. We do not preemptively create
  // new entity form display configuration entries for each existing entity
  // type and bundle whenever a new form mode becomes available.
  // Instead, configuration entries are only created when an entity form
  // display is explicitly configured and saved.
  if (!$entity_form_display) {
    $entity_form_display = EntityFormDisplay::create([
      'targetEntityType' => $entity_type,
      'bundle' => $bundle,
      'mode' => $form_mode,
      'status' => TRUE,
    ]);
  }
  return $entity_form_display;
}