30.04.2026 | Mathias Grab

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

get_all_available_contexts.php
<?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.