Skip to main content

Devbit

How to get a list of all available contexts by context providers

You need to load a list with all context providers available in your Drupal system.
<?php

$all_available_contexts = \Drupal::service('context.repository')->getAvailableContexts();

Issue:

You need to load a list with all context providers available in your Drupal system.

Solution:

Load the context.repository service and its getAllAvailableContexts method using the provided snippet.

Profilfoto Mathias Grab

Mathias Grab

Trainee Webentwicklung

Test

Ihre Drupal-Website zukunftssicher machen

Wir prüfen Ihr System und zeigen, was Sie für AI, Wartung und Upgrades brauchen.