You are here

protected function EntityDisplayFormBase::saveDisplayStatuses in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::saveDisplayStatuses()
  2. 10 core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::saveDisplayStatuses()

Saves the updated display mode statuses.

Parameters

array $display_statuses: An array holding updated form or view mode statuses.

1 call to EntityDisplayFormBase::saveDisplayStatuses()
EntityDisplayFormBase::submitForm in core/modules/field_ui/src/Form/EntityDisplayFormBase.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

core/modules/field_ui/src/Form/EntityDisplayFormBase.php, line 861

Class

EntityDisplayFormBase
Base class for EntityDisplay edit forms.

Namespace

Drupal\field_ui\Form

Code

protected function saveDisplayStatuses($display_statuses) {
  $displays = $this
    ->getDisplays();
  foreach ($displays as $display) {

    // Only update the display if the status is changing.
    $new_status = $display_statuses[$display
      ->get('mode')];
    if ($new_status !== $display
      ->status()) {
      $display
        ->set('status', $new_status);
      $display
        ->save();
    }
  }
}