protected function ConfigSyncImportForm::buildExtensionDetail in Configuration Synchronizer 8.2
Builds the details of a package.
Parameters
string $type: The type of extension (module or theme).
string $name: The machine name of the extension.
array $collection_changelists: Associative array of configuration changes keyed by the type of change.
string $collection: The configuration collection.
Return value
array A render array of a form element.
1 call to ConfigSyncImportForm::buildExtensionDetail()
- ConfigSyncImportForm::buildUpdatesListing in src/
Form/ ConfigSyncImportForm.php - Builds the portion of the form showing a listing of updates.
File
- src/
Form/ ConfigSyncImportForm.php, line 239
Class
Namespace
Drupal\config_sync\FormCode
protected function buildExtensionDetail($type, $name, $collection_changelists) {
switch ($type) {
case 'module':
$label = $this->moduleHandler
->getName($name);
break;
case 'theme':
$label = $this->themeHandler
->getName($name);
break;
}
$element['name'] = [
'data' => [
'#type' => 'html_tag',
'#tag' => 'h3',
'#value' => $label,
],
'class' => [
'config-sync-extension-name',
],
];
foreach ($collection_changelists as $collection => $changelist) {
$extension_config = [];
foreach ([
'create',
'update',
] as $change_type) {
if (isset($changelist[$change_type])) {
$extension_config[$change_type] = [];
foreach ($changelist[$change_type] as $item_name => $item_label) {
$config_type = $this->configUpdateLister
->getTypeNameByConfigName($item_name);
if (!$config_type) {
$config_type = 'system_simple';
}
if ($change_type == 'rename') {
$names = $storage_comparer
->extractRenameNames($item_name);
$route_options = array(
'source_name' => $names['old_name'],
'target_name' => $names['new_name'],
);
}
else {
$route_options = array(
'source_name' => $item_name,
);
}
if ($collection != StorageInterface::DEFAULT_COLLECTION) {
$route_name = 'config_distro.diff_collection';
$route_options['collection'] = $collection;
}
else {
$route_name = 'config_distro.diff';
}
if (!isset($extension_config[$change_type][$config_type])) {
$extension_config[$change_type][$config_type] = [];
}
$extension_config[$change_type][$config_type][$item_name] = [
'#type' => 'link',
'#title' => $item_label,
'#url' => Url::fromRoute($route_name, $route_options),
'#options' => [
'attributes' => [
'class' => [
'use-ajax',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => json_encode([
'width' => 700,
]),
],
],
];
}
}
}
$rows = [];
if ($collection !== StorageInterface::DEFAULT_COLLECTION) {
$rows[] = [
[
'data' => [
'#type' => 'html_tag',
'#tag' => 'h2',
'#value' => $this
->t('@collection configuration collection', [
'@collection' => $collection,
]),
'#colspan' => 2,
],
],
];
}
$change_type_labels = [
// Match the labels used by core.
// @see ConfigSync::buildForm().
'create' => $this
->t('New'),
'update' => $this
->t('Changed'),
];
// List config types for order.
$config_types = $this->configSyncLister
->listConfigTypes();
foreach ($extension_config as $change_type => $change_type_data) {
$rows[] = [
[
'data' => [
'#type' => 'html_tag',
'#tag' => 'strong',
'#value' => $change_type_labels[$change_type],
],
],
[
'data' => [
'#type' => 'html_tag',
'#tag' => 'strong',
'#value' => $this
->t('View differences'),
],
],
];
foreach ($config_types as $config_type => $config_type_label) {
if (isset($change_type_data[$config_type])) {
$row = [];
$row[] = [
'data' => [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => $config_type_label,
'#attributes' => [
'title' => $config_type,
'class' => [
'config-sync-item-type-label',
],
],
],
];
$row[] = [
'data' => [
'#theme' => 'item_list',
'#items' => $change_type_data[$config_type],
'#context' => [
'list_style' => 'comma-list',
],
],
'class' => [
'item',
],
];
$rows[] = $row;
}
}
}
}
$element['details'] = [
'data' => [
'#type' => 'table',
'#rows' => $rows,
],
];
return $element;
}