Problem/Motivation

Having an entity context available makes it easier to access the "current" entity for context aware plugins: https://www.drupal.org/docs/drupal-apis/plugin-api/plugin-contexts

This effectively prevents duplication of the code that checks and loads an entity from route parameters. A practical example of this would be creating a block that is only displayed when a log entity is provided in the current page context.

Drupal core provides a context provider for both node and taxonomy term routes:

There has been talk of making these core implementations more generic and be provided for all entity types (I saw @pcambra suggest this somewhere but can't find it now). I think this is a good idea in the long run but lets implement one ourselves now.

Related issues:

Steps to reproduce

N/A

Proposed resolution

Mimic the drupal core node/term route context.

Remaining tasks

Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork log-3261662

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

paul121 created an issue. See original summary.

paul121’s picture

Issue summary: View changes

Adding related core issues

paul121’s picture

Status: Active » Needs review
m.stenta’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3210666: Add a base class, or possibly deriver for entity route contexts, +#3138465: Add a generic entity route context

This looks good to me - thanks @paul121!

  • m.stenta committed 162b9c9 on 2.x authored by paul121
    Issue #3261662 by paul121: Provide a log context on log routes
    
m.stenta’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.