Implements hook_entity_get_display().

File

src/Controller/ExifSettingsController.php, line 603

Class

ExifSettingsController
Class ExifSettingsController manage action of settings pages.

Namespace

Drupal\exif\Controller

Code

public function entity_get_display($entity_type, $bundle, $view_mode) {
    // Try loading the display from configuration.
    $display = EntityViewDisplay::load($entity_type . '.' . $bundle . '.' . $view_mode);
    // If not found, create a fresh display object. We do not preemptively
    // create new entity_view_display configuration entries for each existing
    // entity type and bundle whenever a new view mode becomes available.
    // Instead, configuration entries are only created when a display object
    // is explicitly configured and saved.
    if (!$display) {
        $display = EntityViewDisplay::create([
            'targetEntityType' => $entity_type,
            'bundle' => $bundle,
            'mode' => $view_mode,
            'status' => TRUE,
        ]);
    }
    return $display;
}