You are here

protected function PdbBlock::getContextsValues in Decoupled Blocks 8

Get the value of contexts.

Parameters

\Drupal\Component\Plugin\Context\ContextInterface[] $contexts: The contexts to get value.

Return value

array An array of contexts values.

1 call to PdbBlock::getContextsValues()
PdbBlock::build in src/Plugin/Block/PdbBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/PdbBlock.php, line 176

Class

PdbBlock
Class PdbBlock.

Namespace

Drupal\pdb\Plugin\Block

Code

protected function getContextsValues(array $contexts) {
  $context_values = [];
  foreach ($contexts as $key => $context) {
    $data = $context
      ->getContextData();
    if ($data instanceof EntityAdapter) {
      $this
        ->getContextEntityValue($key, $data, $context_values);
    }
    else {

      // Get the data value otherwise.
      $context_values[$key] = $data
        ->getValue();
    }
  }
  return $context_values;
}