You are here

protected function PanelsContentForm::getContextAsTokenData in Panels 8.4

Get context as token data.

Parameters

array $contexts: Context.

Return value

array Array of tokens.

1 call to PanelsContentForm::getContextAsTokenData()
PanelsContentForm::buildForm in src/Form/PanelsContentForm.php
Form constructor.

File

src/Form/PanelsContentForm.php, line 284

Class

PanelsContentForm
Provides a form for editing a panel variant display's content.

Namespace

Drupal\panels\Form

Code

protected function getContextAsTokenData(array $contexts) {
  $tokens = [];
  foreach ($contexts as $context_key => $context) {
    if (strpos($context
      ->getContextDefinition()
      ->getDataType(), 'entity:') === 0) {
      $token_type = substr($context
        ->getContextDefinition()
        ->getDataType(), 7);
      if ($token_type == 'taxonomy_term') {
        $token_type = 'term';
      }
      $tokens[] = $token_type;
    }
  }
  return $tokens;
}