function EntityDisplayModeFormBase::getDisplayByContext

Same name and namespace in other branches
  1. 10 core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::getDisplayByContext()

Returns View or Form display based on display context.

Parameters

string $bundle: The entity bundle to load the display for.

string $display_mode_name: The display mode name to load the display for.

Return value

\Drupal\Core\Entity\Display\EntityFormDisplayInterface|\Drupal\Core\Entity\Display\EntityViewDisplayInterface|null Returns the display, or NULL if one does not exist.

2 calls to EntityDisplayModeFormBase::getDisplayByContext()
EntityDisplayModeFormBase::form in core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php
Gets the actual form array to be built.
EntityDisplayModeFormBase::save in core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php
Form submission handler for the 'save' action.

File

core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php, line 294

Class

EntityDisplayModeFormBase
Provides the generic base class for entity display mode forms.

Namespace

Drupal\field_ui\Form

Code

private function getDisplayByContext(string $bundle, string $display_mode_name) : EntityFormDisplayInterface|EntityViewDisplayInterface|null {
    return match ($this->displayContext) {    'view' => $this->getViewDisplay($bundle, $display_mode_name),
        'form' => $this->getFormDisplay($bundle, $display_mode_name),
    
    };
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.