Chris@14: contextRepository) { Chris@14: $this->contextRepository = \Drupal::service('context.repository'); Chris@14: } Chris@14: return $this->contextRepository; Chris@14: } Chris@14: Chris@14: /** Chris@14: * Provides all available contexts, both global and section_storage-specific. Chris@14: * Chris@14: * @param \Drupal\layout_builder\SectionStorageInterface $section_storage Chris@14: * The section storage. Chris@14: * Chris@14: * @return \Drupal\Core\Plugin\Context\ContextInterface[] Chris@14: * The array of context objects. Chris@14: */ Chris@14: protected function getAvailableContexts(SectionStorageInterface $section_storage) { Chris@14: // Get all globally available contexts that have a defined value. Chris@14: $contexts = array_filter($this->contextRepository()->getAvailableContexts(), function (ContextInterface $context) { Chris@14: return $context->hasContextValue(); Chris@14: }); Chris@14: Chris@14: // Add in the per-section_storage contexts. Chris@18: $contexts += $section_storage->getContextsDuringPreview(); Chris@14: return $contexts; Chris@14: } Chris@14: Chris@14: }