function EntityDisplayFormBase::getDisplays

Same name in other branches
  1. 9 core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::getDisplays()
  2. 8.9.x core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::getDisplays()
  3. 11.x core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::getDisplays()

Returns entity (form) displays for the current entity display type.

Return value

\Drupal\Core\Entity\Display\EntityDisplayInterface[] An array holding entity displays or entity form displays.

2 calls to EntityDisplayFormBase::getDisplays()
EntityDisplayFormBase::getDisplayStatuses in core/modules/field_ui/src/Form/EntityDisplayFormBase.php
Returns form or view modes statuses for the bundle used by this form.
EntityDisplayFormBase::saveDisplayStatuses in core/modules/field_ui/src/Form/EntityDisplayFormBase.php
Saves the updated display mode statuses.

File

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

Class

EntityDisplayFormBase
Base class for EntityDisplay edit forms.

Namespace

Drupal\field_ui\Form

Code

protected function getDisplays() {
    $load_ids = [];
    $display_entity_type = $this->entity
        ->getEntityTypeId();
    $entity_type = $this->entityTypeManager
        ->getDefinition($display_entity_type);
    $config_prefix = $entity_type->getConfigPrefix();
    $ids = $this->configFactory()
        ->listAll($config_prefix . '.' . $this->entity
        ->getTargetEntityTypeId() . '.' . $this->entity
        ->getTargetBundle() . '.');
    foreach ($ids as $id) {
        $config_id = str_replace($config_prefix . '.', '', $id);
        [
            ,
            ,
            $display_mode,
        ] = explode('.', $config_id);
        if ($display_mode != 'default') {
            $load_ids[] = $config_id;
        }
    }
    return $this->entityTypeManager
        ->getStorage($display_entity_type)
        ->loadMultiple($load_ids);
}

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