You are here

private static function SettingsFormBuilder::buildTokenLink in UI Patterns Settings 8.2

Build a hidden tree link token for performance reasons.

Forms with class .js-ui-patterns-settings-show-token-link will generate Browse token button which click on the hidden link. This will reduce the number of browse buttons.

Parameters

array $form: The form.

2 calls to SettingsFormBuilder::buildTokenLink()
SettingsFormBuilder::displayForm in src/Form/SettingsFormBuilder.php
Build pattern settings for display form.
SettingsFormBuilder::layoutForm in src/Form/SettingsFormBuilder.php
Build pattern settings fieldset.

File

src/Form/SettingsFormBuilder.php, line 26

Class

SettingsFormBuilder
Build settings in manage display form.

Namespace

Drupal\ui_patterns_settings\Form

Code

private static function buildTokenLink(array &$form) {
  $content_entity_types = [];
  $entity_type_definations = \Drupal::entityTypeManager()
    ->getDefinitions();

  /** @var EntityTypeInterface $definition */
  foreach ($entity_type_definations as $definition) {
    if ($definition instanceof ContentEntityType) {
      $content_entity_types[] = $definition
        ->id();
    }
  }
  $form['token_link'] = [
    '#prefix' => '<div id="ui-patterns-settings-token-link">',
    '#suffix' => '</div>',
    '#theme' => 'token_tree_link',
    '#token_types' => $content_entity_types,
    '#show_restricted' => TRUE,
    '#weight' => 90,
  ];
}