You are here

public function FormModeManager::filterExcludedFormModes in Form mode manager 8

Same name and namespace in other branches
  1. 8.2 src/FormModeManager.php \Drupal\form_mode_manager\FormModeManager::filterExcludedFormModes()

Filter a form mode collection to exclude all desired form mode id.

Parameters

array $form_mode: A form mode collection to be filtered.

string $entity_type_id: The entity type ID of entity.

bool $ignore_excluded: Joker to determine if form modes to exclude list are used or ignored.

Return value

array The collection without uneeded form modes.

Overrides FormModeManagerInterface::filterExcludedFormModes

2 calls to FormModeManager::filterExcludedFormModes()
FormModeManager::getAllFormModesDefinitions in src/FormModeManager.php
Gets the entity form mode info for all entity types used.
FormModeManager::getFormModesByEntity in src/FormModeManager.php
Gets the entity form mode info for a specific entity type.

File

src/FormModeManager.php, line 170

Class

FormModeManager
FormDisplayManager service.

Namespace

Drupal\form_mode_manager

Code

public function filterExcludedFormModes(array &$form_modes, $entity_type_id, $ignore_excluded) {
  foreach ($form_modes as $form_mode_id => $form_mode_definition) {

    // Exclude if current form_mode is malformed eg: "entity_test".
    if ($this
      ->candidateToExclude($form_mode_definition, $entity_type_id)) {
      unset($form_modes[$form_mode_id]);
    }
    elseif (!$ignore_excluded && $this
      ->formModeIsExcluded($this
      ->getFormModeExcluded($entity_type_id), $form_mode_id)) {
      unset($form_modes[$form_mode_id]);
    }
  }
}