You are here

protected function ConfigSyncInitialize::buildUpdatesListing in Configuration Synchronizer 8

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 ConfigSyncInitialize::buildUpdatesListing()
ConfigSyncInitialize::buildForm in src/Form/ConfigSyncInitialize.php
Form constructor.

File

src/Form/ConfigSyncInitialize.php, line 143

Class

ConfigSyncInitialize

Namespace

Drupal\config_sync\Form

Code

protected function buildUpdatesListing($type, array $extension_changelists) {
  $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 = [];
  $rows = [];
  foreach ($extension_changelists as $name => $changelist) {
    $options[$name] = $this
      ->buildExtensionDetail($type, $name, $changelist);
  }
  $element = [
    // @todo: convert to a tableselect once we refresh the extension
    // snapshot values of a given config item on update.
    // '#type' => 'tableselect',
    '#type' => 'table',
    '#header' => $header,
    // '#options' => $options,
    '#rows' => $options,
    '#attributes' => [
      'class' => [
        'config-sync-listing',
      ],
    ],
    '#default_value' => array_fill_keys(array_keys($options), TRUE),
  ];
  return $element;
}