You are here

protected function WebformEntitySettingsGeneralForm::buildDialogSource in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/EntitySettings/WebformEntitySettingsGeneralForm.php \Drupal\webform\EntitySettings\WebformEntitySettingsGeneralForm::buildDialogSource()

Build dialog source.

Parameters

array $link: Webform link.

Return value

array A renderable array containing dialog source

1 call to WebformEntitySettingsGeneralForm::buildDialogSource()
WebformEntitySettingsGeneralForm::form in src/EntitySettings/WebformEntitySettingsGeneralForm.php
Gets the actual form array to be built.

File

src/EntitySettings/WebformEntitySettingsGeneralForm.php, line 584

Class

WebformEntitySettingsGeneralForm
Webform general settings.

Namespace

Drupal\webform\EntitySettings

Code

protected function buildDialogSource(array $link) {
  $source_entity_link = $link;
  $source_entity_link['#url'] = clone $source_entity_link['#url'];
  $source_entity_link['#url']
    ->setOption('query', [
    'source_entity_type' => 'ENTITY_TYPE',
    'source_entity_id' => 'ENTITY_ID',
  ]);
  return [
    'data' => [
      'webform' => [
        '#theme' => 'webform_codemirror',
        '#type' => 'html',
        '#code' => (string) \Drupal::service('renderer')
          ->renderPlain($link),
        '#suffix' => '<br/>',
      ],
      'source_entity' => [
        'container' => [
          '#type' => 'container',
          '#attributes' => [
            'class' => [
              'js-form-item',
            ],
          ],
          '#states' => [
            'visible' => [
              ':input[name="form_prepopulate_source_entity"]' => [
                'checked' => TRUE,
              ],
            ],
          ],
          'link' => [
            '#theme' => 'webform_codemirror',
            '#type' => 'html',
            '#code' => (string) \Drupal::service('renderer')
              ->renderPlain($source_entity_link),
          ],
        ],
      ],
    ],
  ];
}