You are here

protected function CshsWidget::getPerDisplaySettings in Client-side Hierarchical Select 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldWidget/CshsWidget.php \Drupal\cshs\Plugin\Field\FieldWidget\CshsWidget::getPerDisplaySettings()

Returns the per display widget settings for the entity type.

Return value

array[] The per display widget settings.

1 call to CshsWidget::getPerDisplaySettings()
CshsWidget::getSettings in src/Plugin/Field/FieldWidget/CshsWidget.php
Returns the array of settings, including defaults for missing settings.

File

src/Plugin/Field/FieldWidget/CshsWidget.php, line 181

Class

CshsWidget
Provides "cshs" field widget.

Namespace

Drupal\cshs\Plugin\Field\FieldWidget

Code

protected function getPerDisplaySettings() : array {
  if ($this->perDisplaySettings === NULL) {
    $this->perDisplaySettings = [];
    $field_name = $this->fieldDefinition
      ->getName();

    // Load all form displays for the entity type the field is attached to.
    $form_displays = $this
      ->getStorage('entity_form_display')
      ->loadByProperties([
      'targetEntityType' => $this->fieldDefinition
        ->getTargetEntityTypeId(),
    ]);
    foreach ($form_displays as $form_display) {
      \assert($form_display instanceof EntityFormDisplay);
      if (($widget = $form_display
        ->getComponent($field_name)) && CshsElement::ID === ($widget['type'] ?? '')) {
        $this->perDisplaySettings[] = $widget['settings'] ?? [];
      }
    }
  }
  return $this->perDisplaySettings;
}