protected function AddVariantStaticContextConfigure::addContext in Page Manager 8.4
Same name and namespace in other branches
- 8 page_manager_ui/src/Form/AddVariantStaticContextConfigure.php \Drupal\page_manager_ui\Form\AddVariantStaticContextConfigure::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
- page_manager_ui/
src/ Form/ AddVariantStaticContextConfigure.php, line 45
Class
Namespace
Drupal\page_manager_ui\FormCode
protected function addContext($cached_values, $context_id, ContextInterface $context) {
/** @var $page_variant \Drupal\page_manager\PageVariantInterface */
$page_variant = $this
->getPageVariant($cached_values);
$context_config = [
'label' => $context
->getContextDefinition()
->getLabel(),
'type' => $context
->getContextDefinition()
->getDataType(),
'description' => $context
->getContextDefinition()
->getDescription(),
'value' => strpos($context
->getContextDefinition()
->getDataType(), 'entity:') === 0 ? $context
->getContextValue()
->uuid() : $context
->getContextValue(),
];
$page_variant
->setStaticContext($context_id, $context_config);
$cached_values['page_variant'] = $page_variant;
return $cached_values;
}