You are here

protected function ConfigSyncImportForm::buildUpdatesListing in Configuration Synchronizer 8.2

Builds the portion of the form showing a listing of updates.

Parameters

string $type: The type of extension (module or theme).

array $extension_changelists: Associative array of configuration changes keyed by extension name.

Return value

array A render array of a form element.

1 call to ConfigSyncImportForm::buildUpdatesListing()
ConfigSyncImportForm::buildForm in src/Form/ConfigSyncImportForm.php
Form constructor.

File

src/Form/ConfigSyncImportForm.php, line 188

Class

ConfigSyncImportForm

Namespace

Drupal\config_sync\Form

Code

protected function buildUpdatesListing($type, array $extension_changelists) {
  $plugin_data = $this->state
    ->get('config_sync.plugins_previous', []);
  $type_labels = [
    'module' => $this
      ->t('Module'),
    'theme' => $this
      ->t('Theme'),
  ];
  $header = [
    'name' => [
      'data' => $this
        ->t('@type name', [
        '@type' => $type_labels[$type],
      ]),
    ],
    'details' => [
      'data' => $this
        ->t('Available configuration changes'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
  ];
  $options = [];
  $default_value = [];
  foreach ($extension_changelists as $name => $collection_changelists) {
    $options[$name] = $this
      ->buildExtensionDetail($type, $name, $collection_changelists);

    // Status can be overridden in the state.
    $default_value[$name] = !isset($plugin_data[$type][$name]['status']) || $plugin_data[$type][$name]['status'] === TRUE;
  }
  $element = [
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#multiple' => TRUE,
    '#attributes' => [
      'class' => [
        'config-sync-listing',
      ],
    ],
    '#default_value' => $default_value,
  ];
  return $element;
}