You are here

protected function ListPaymentStatuses::buildListingLevel in Payment 8.2

Helper function for self::listing() to build table rows.

Parameters

array[] $hierarchy: Keys are plugin IDs, and values are arrays of the same structure as this parameter. The depth is unlimited.

integer $depth: The depth of $hierarchy's top-level items as seen from the original hierarchy's root (this function is recursive), starting with 0.

Return value

array A render array.

1 call to ListPaymentStatuses::buildListingLevel()
ListPaymentStatuses::execute in src/Controller/ListPaymentStatuses.php
Lists all payment statuses.

File

src/Controller/ListPaymentStatuses.php, line 78

Class

ListPaymentStatuses
Handles the "list payment methods" route.

Namespace

Drupal\payment\Controller

Code

protected function buildListingLevel(array $hierarchy, $depth) {
  $rows = [];
  foreach ($hierarchy as $plugin_id => $children) {
    $definition = $this->paymentStatusManager
      ->getDefinition($plugin_id);
    $operations_provider = $this->paymentStatusManager
      ->getOperationsProvider($plugin_id);
    $indentation = [
      '#theme' => 'indentation',
      '#size' => $depth,
    ];
    $rows[$plugin_id] = [
      'label' => [
        '#markup' => $this->renderer
          ->render($indentation) . $definition['label'],
      ],
      'description' => [
        '#markup' => $definition['description'],
      ],
      'operations' => [
        '#type' => 'operations',
        '#links' => $operations_provider ? $operations_provider
          ->getOperations($plugin_id) : [],
      ],
    ];
    $rows = array_merge($rows, $this
      ->buildListingLevel($children, $depth + 1));
  }
  return $rows;
}