You are here

public function OrderViewBuilder::buildComponents in Ubercart 8.4

Builds the component fields and properties of a set of entities.

Parameters

&$build: The renderable array representing the entity content.

\Drupal\Core\Entity\EntityInterface[] $entities: The entities whose content is being built.

\Drupal\Core\Entity\Display\EntityViewDisplayInterface[] $displays: The array of entity view displays holding the display options configured for the entity components, keyed by bundle name.

string $view_mode: The view mode in which the entity is being viewed.

Overrides EntityViewBuilder::buildComponents

File

uc_order/src/OrderViewBuilder.php, line 58

Class

OrderViewBuilder
View builder for orders.

Namespace

Drupal\uc_order

Code

public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
  parent::buildComponents($build, $entities, $displays, $view_mode);
  $panes = $this->orderPaneManager
    ->getPanes();
  $components = $displays['uc_order']
    ->getComponents();
  foreach ($entities as $id => $order) {
    foreach ($panes as $pane_id => $pane) {

      // Skip panes that are hidden in "Manage display".
      if (!isset($components[$pane_id])) {
        continue;
      }
      if ($contents = $pane
        ->view($order, $view_mode)) {
        $build[$id][$pane_id] = [
          '#type' => 'container',
          '#attributes' => [
            'id' => 'order-pane-' . $pane_id,
            'class' => array_merge([
              'order-pane',
            ], $pane
              ->getClasses()),
          ],
        ];
        if ($title = $pane
          ->getTitle()) {
          $build[$id][$pane_id]['title'] = [
            '#type' => 'container',
            '#markup' => $title . ':',
            '#attributes' => [
              'class' => [
                'order-pane-title',
              ],
            ],
          ];
        }
        $build[$id][$pane_id]['pane'] = $contents;
      }
    }
  }
}