You are here

protected static function ConflictResolutionDialogFormBuilder::buildNestedItemList in Conflict 8.2

Builds the render array for the nested item list of titles.

Parameters

array $titles: An array containing the titles.

bool $root_call: (optional) Whether this is a root call. As this is a recursive function it requires a way to differ between the first and subsequent calls. Defaults to TRUE.

string|NULL $root_title: (optional) The title to use for the most upper (root) list. Defaults to NULL.

Return value

array A render array containing a nested item list of titles.

2 calls to ConflictResolutionDialogFormBuilder::buildNestedItemList()
ConflictResolutionDialogFormBuilder::processForm in src/Form/ConflictResolutionDialogFormBuilder.php
Adds the conflict resolution overview to the form.
ConflictResolutionDialogFormBuilder::resolveConflictsAjax in src/Form/ConflictResolutionDialogFormBuilder.php
Ajax callback returning the UI for conflict resolution.

File

src/Form/ConflictResolutionDialogFormBuilder.php, line 305

Class

ConflictResolutionDialogFormBuilder

Namespace

Drupal\conflict\Form

Code

protected static function buildNestedItemList($titles, $root_call = TRUE, $root_title = NULL) {
  if ($titles) {
    $title = array_shift($titles);
    if ($root_call) {
      if ($titles) {
        $render = [
          [
            '#theme' => 'item_list',
            '#list_type' => 'ul',
            '#title' => $root_title,
            '#items' => [
              [
                [
                  '#markup' => $title,
                ],
                [
                  'titles' => static::buildNestedItemList($titles, FALSE),
                ],
              ],
            ],
          ],
        ];
      }
      else {
        $render = [
          [
            '#theme' => 'item_list',
            '#list_type' => 'ul',
            '#title' => $root_title,
            '#items' => [
              [
                '#markup' => $title,
              ],
            ],
          ],
        ];
      }
    }
    elseif ($titles) {
      $render = [
        [
          '#markup' => $title,
        ],
        [
          '#theme' => 'item_list',
          '#list_type' => 'ul',
          '#items' => [
            'titles' => static::buildNestedItemList($titles, FALSE),
          ],
        ],
      ];
    }
    else {
      $render = [
        '#markup' => $title,
      ];
    }
  }
  else {
    $render = [];
  }
  return $render;
}