Problem / Motivation

The content_singleton module does not register a route context provider for the
entity:content_singleton data type. This means condition plugins that declare an
entity:content_singleton context requirement — most notably the core-derived
entity_bundle:content_singleton condition — can never resolve their required context
from the runtime context pool.

This surfaces as a real breakage when using the
Notification Message module's
entity_bundle:content_singleton condition to target in-page notifications to specific
content singleton bundles (e.g. restrict a notification to only appear on a branches_search
singleton). The condition always evaluates FALSE, so the notification never displays,
regardless of how it is configured.

The root cause is in NotificationMessage::computeConditionInstance(): when a condition
plugin declares a required context that cannot be found in the available runtime contexts,
the method short-circuits and returns FALSE without ever calling evaluate().
Because no entity:content_singleton context is registered anywhere, every
entity_bundle:content_singleton condition fails unconditionally.

Compare with Drupal core, where every content entity type that can appear as a canonical route
provides a matching route context service — for example:

  • Nodes → @node.node_route_context:node (NodeRouteContext)
  • Taxonomy terms → @taxonomy_term.taxonomy_term_route_context:taxonomy_term

content_singleton is missing the equivalent.

Steps to Reproduce

  1. Install content_singleton and notification_message.
  2. Create a content singleton type (e.g. branches_search) and a corresponding singleton entity accessible at a public path (e.g. /branches).
  3. Create an in-page notification_message entity and configure its
    entity_bundle:content_singleton condition to target the branches_search bundle.
  4. Visit the singleton's path.
  5. Observe: the notification does not appear, even though the conditions appear correctly configured.

Proposed Resolution

Add a ContentSingletonRouteContext class implementing
ContextProviderInterface that reads the content_singleton route
parameter from the current route match and exposes it as a non-required
entity:content_singleton context with a route cache context.
Register the service with the context_provider tag.

This follows the identical pattern used by NodeRouteContext in Drupal core
(web/core/modules/node/src/ContextProvider/NodeRouteContext.php).

Remaining Tasks

  • Review and commit the patch
  • Add test coverage (kernel test asserting the context is available on a content_singleton canonical route)

Module Version

Reproduced on content_singleton 1.x / Drupal 11.2.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

philip_stier created an issue.

philip_stier’s picture

Patch ready for merge – tested successfully on site.