You are here

protected function ExifSettingsController::configureEntityViewDisplay in Exif 8

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

Ensure field is visible in default view.

Parameters

string $field_name: Name of the field to add to the view.

int $formatter_id: Formatter associated to this view and this field or NULL if default.

File

src/Controller/ExifSettingsController.php, line 566

Class

ExifSettingsController
Class ExifSettingsController manage action of settings pages.

Namespace

Drupal\exif\Controller

Code

protected function configureEntityViewDisplay($field_name, $formatter_id = NULL) {

  // Make sure the field is displayed in the 'default' view mode (using
  // default formatter and settings). It stays hidden for other view
  // modes until it is explicitly configured.
  $options = $formatter_id ? [
    'type' => $formatter_id,
  ] : [];
  $this
    ->entity_get_display($this->entityTypeId, $this->bundle, 'default')
    ->setComponent($field_name, $options)
    ->save();
}