You are here

public function FormsStepsManager::getAllFormModesDefinitions in Forms Steps 8

Get all form modes per entity type.

Return value

array Returns a list of form modes defined for all entity types in forms_steps entities.

File

src/Service/FormsStepsManager.php, line 231

Class

FormsStepsManager
Class FormsStepsManager.

Namespace

Drupal\forms_steps\Service

Code

public function getAllFormModesDefinitions() {

  // Only managing node at this time. Improvment require.
  $all_form_modes = [];

  // Retrieving all entity types referenced in any forms_steps entity.
  $entityTypes = $this
    ->getAllFormStepsEntityTypes();

  // Gather all form modes for each entity type.
  foreach ($entityTypes as $entityType) {
    $form_modes = $this->entityDisplayRepository
      ->getFormModes($entityType);
    foreach ($form_modes as $key => $value) {
      if (!empty($key) && $value['targetEntityType'] === $entityType) {
        $all_form_modes[$entityType][] = $key;
      }
    }
  }
  return $all_form_modes;
}