Chris@0: 'table',
Chris@0: '#header' => $header,
Chris@0: '#attributes' => ['id' => 'language-negotiation-methods-' . $type],
Chris@0: '#tabledrag' => [
Chris@0: [
Chris@0: 'action' => 'order',
Chris@0: 'relationship' => 'sibling',
Chris@0: 'group' => 'language-method-weight-' . $type,
Chris@0: ],
Chris@0: ],
Chris@0: ];
Chris@0:
Chris@0: foreach ($form[$type]['title'] as $id => $element) {
Chris@0: // Do not take form control structures.
Chris@0: if (is_array($element) && Element::child($id)) {
Chris@0: $table[$id]['#attributes']['class'][] = 'draggable';
Chris@0: $table[$id]['#weight'] = $element['#weight'];
Chris@0:
Chris@0: $table[$id]['title'] = [
Chris@0: '#prefix' => '',
Chris@0: $form[$type]['title'][$id],
Chris@0: '#suffix' => '',
Chris@0: ];
Chris@0: $table[$id]['description'] = $form[$type]['description'][$id];
Chris@0: $table[$id]['enabled'] = $form[$type]['enabled'][$id];
Chris@0: $table[$id]['weight'] = $form[$type]['weight'][$id];
Chris@0: if ($form[$type]['#show_operations']) {
Chris@0: $table[$id]['operation'] = $form[$type]['operation'][$id];
Chris@0: }
Chris@0: // Unset to prevent rendering along with children.
Chris@0: unset($form[$type]['title'][$id]);
Chris@0: unset($form[$type]['description'][$id]);
Chris@0: unset($form[$type]['enabled'][$id]);
Chris@0: unset($form[$type]['weight'][$id]);
Chris@0: unset($form[$type]['operation'][$id]);
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: // Unset configurable to prevent rendering twice with children.
Chris@0: $configurable = isset($form[$type]['configurable']) ? $form[$type]['configurable'] : NULL;
Chris@0: unset($form[$type]['configurable']);
Chris@0:
Chris@0: $variables['language_types'][] = [
Chris@0: 'type' => $type,
Chris@0: 'title' => $form[$type]['#title'],
Chris@0: 'description' => $form[$type]['#description'],
Chris@0: 'configurable' => $configurable,
Chris@0: 'table' => $table,
Chris@0: 'children' => $form[$type],
Chris@0: 'attributes' => new Attribute(),
Chris@0: ];
Chris@0: // Prevent the type from rendering with the remaining form child elements.
Chris@0: unset($form[$type]);
Chris@0: }
Chris@0:
Chris@0: $variables['children'] = $form;
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Prepares variables for language content settings table templates.
Chris@0: *
Chris@0: * Default template: language-content-settings-table.html.twig.
Chris@0: *
Chris@0: * @param array $variables
Chris@0: * An associative array containing:
Chris@0: * - element: An associative array containing the properties of the element.
Chris@0: * Properties used: #bundle_label, #title.
Chris@0: */
Chris@0: function template_preprocess_language_content_settings_table(&$variables) {
Chris@0: // Add a render element representing the bundle language settings table.
Chris@0: $element = $variables['element'];
Chris@0:
Chris@0: $header = [
Chris@0: [
Chris@0: 'data' => $element['#bundle_label'],
Chris@0: 'class' => ['bundle'],
Chris@0: ],
Chris@0: [
Chris@0: 'data' => t('Configuration'),
Chris@0: 'class' => ['operations'],
Chris@0: ],
Chris@0: ];
Chris@0:
Chris@0: $rows = [];
Chris@0: foreach (Element::children($element) as $bundle) {
Chris@0: $rows[$bundle] = [
Chris@0: 'data' => [
Chris@0: [
Chris@0: 'data' => [
Chris@0: '#prefix' => '',
Chris@0: '#plain_text' => $element[$bundle]['settings']['#label'],
Chris@0: ],
Chris@0: 'class' => ['bundle'],
Chris@0: ],
Chris@0: [
Chris@0: 'data' => $element[$bundle]['settings'],
Chris@0: 'class' => ['operations'],
Chris@0: ],
Chris@0: ],
Chris@0: 'class' => ['bundle-settings'],
Chris@0: ];
Chris@0: }
Chris@0:
Chris@0: $variables['title'] = $element['#title'];
Chris@0: $variables['build'] = [
Chris@0: '#header' => $header,
Chris@0: '#rows' => $rows,
Chris@0: '#type' => 'table',
Chris@0: ];
Chris@0: }