You are here

protected function PanelizerWizardContextConfigure::addContext in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 src/Form/PanelizerWizardContextConfigure.php \Drupal\panelizer\Form\PanelizerWizardContextConfigure::addContext()
  2. 8.3 src/Form/PanelizerWizardContextConfigure.php \Drupal\panelizer\Form\PanelizerWizardContextConfigure::addContext()

Custom logic for adding a context to the cached_values contexts array.

Parameters

array $cached_values: The cached_values currently in use.

string $context_id: The context identifier.

\Drupal\Core\Plugin\Context\ContextInterface $context: The context to add or update within the cached values.

Return value

mixed Return the $cached_values

Overrides ContextConfigure::addContext

File

src/Form/PanelizerWizardContextConfigure.php, line 53

Class

PanelizerWizardContextConfigure

Namespace

Drupal\panelizer\Form

Code

protected function addContext($cached_values, $context_id, ContextInterface $context) {
  $cached_values['contexts'][$context_id] = [
    'label' => $context
      ->getContextDefinition()
      ->getLabel(),
    'type' => $context
      ->getContextDefinition()
      ->getDataType(),
    'description' => $context
      ->getContextDefinition()
      ->getDescription(),
    'value' => strpos($context
      ->getContextDefinition()
      ->getDataType(), 'entity:') === 0 ? $context
      ->getContextValue()
      ->uuid() : $context
      ->getContextValue(),
  ];
  return $cached_values;
}