You are here

public function PageExposure::initFormEntityConfig in Flexiform 8

Initialise the enhancer config..

Return value

array The initial config for the enhancer.

File

src/Plugin/FormEnhancer/PageExposure.php, line 173

Class

PageExposure
Plugin for exposing custom form modes on pages.

Namespace

Drupal\flexiform\Plugin\FormEnhancer

Code

public function initFormEntityConfig() {
  $target_entity_type_id = $this
    ->getFormDisplay()
    ->getTargetEntityTypeId();
  $mode = $this
    ->getFormDisplay()
    ->getMode();
  $target_entity_type = $this->entityTypeManager
    ->getDefinition($target_entity_type_id);
  $form_mode = $this
    ->entityFormModeStorage()
    ->load("{$target_entity_type_id}.{$mode}");
  $form_entity_settings = [];
  if (($settings = $form_mode
    ->getThirdPartySetting('flexiform', 'exposure')) && !empty($settings['parameters'])) {
    foreach ($settings['parameters'] as $namespace => $entity_info) {
      if ($namespace == 'base_entity') {
        continue;
      }
      $form_entity_settings[$namespace] = [
        'entity_type' => $entity_info['entity_type'],
        'bundle' => $namespace != 'base_entity' ? $entity_info['bundle'] : $this
          ->getFormDisplay()
          ->getTargetBundle(),
        'plugin' => 'provided',
        'label' => $namespace,
      ];
    }
  }
  return $form_entity_settings;
}