function RequiredContext::renderContexts

Same name in other branches
  1. 8.x-3.x src/Form/RequiredContext.php \Drupal\ctools\Form\RequiredContext::renderContexts()

Render The contexts in the form.

Parameters

$cached_values: Cached context values.

Return value

array The rendered contexts.

1 call to RequiredContext::renderContexts()
RequiredContext::buildForm in src/Form/RequiredContext.php
Form constructor.

File

src/Form/RequiredContext.php, line 140

Class

RequiredContext
Required Context Form.

Namespace

Drupal\ctools\Form

Code

public function renderContexts($cached_values) {
    $configured_contexts = [];
    foreach ($this->getContexts($cached_values) as $row => $context) {
        [
            $plugin_id,
            $label,
            $machine_name,
            $description,
        ] = array_values($context);
        [
            $route_name,
            $route_parameters,
        ] = $this->getOperationsRouteInfo($cached_values, $cached_values['id'], $row);
        $build = [
            '#type' => 'operations',
            '#links' => $this->getOperations($route_name, $route_parameters),
        ];
        $configured_contexts[] = [
            $this->t('<strong>Label:</strong> @label<br /> <strong>Type:</strong> @type', [
                '@label' => $label,
                '@type' => $plugin_id,
            ]),
            $this->t('@description', [
                '@description' => $description,
            ]),
            'operations' => [
                'data' => $build,
            ],
        ];
    }
    return $configured_contexts;
}