You are here

function template_preprocess_content_lock_settings_entities in Content locking (anti-concurrent editing) 8

Same name and namespace in other branches
  1. 8.2 content_lock.module \template_preprocess_content_lock_settings_entities()

Prepares variables for content lock entity settings templates.

Default template: content-lock-settings-entities.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #title.

File

./content_lock.module, line 402
Content lock - Main functions of the module.

Code

function template_preprocess_content_lock_settings_entities(&$variables) {
  $element = $variables['element'];
  $header = [
    [
      'data' => $element['bundles']['#title'],
      'class' => [
        'bundle',
      ],
    ],
    [
      'data' => t('Configuration'),
      'class' => [
        'operations',
      ],
    ],
  ];
  $rows = [];
  foreach (Element::children($element['bundles']) as $bundle) {
    $rows[$bundle] = [
      'data' => [
        [
          'data' => $element['bundles'][$bundle],
          'class' => [
            'bundle',
          ],
        ],
      ],
      'class' => [],
    ];
    if ($bundle == '*') {
      $rows[$bundle]['data'][] = [
        'data' => $element['settings'],
        'class' => [
          'operations',
        ],
      ];
    }
    else {
      $rows[$bundle]['data'][] = [
        'data' => t('Uses "all" settings'),
        'class' => [
          'operations',
        ],
      ];
      $rows[$bundle]['class'][] = 'bundle-settings';
    }
  }
  $variables['title'] = $element['#title'];
  $variables['build'] = [
    '#header' => $header,
    '#rows' => $rows,
    '#type' => 'table',
  ];
}