Upcast node parameter in route

Created on 6 January 2023, about 2 years ago
Updated 22 August 2024, 5 months ago

Problem/Motivation

I have a custom theme that calls a hook_theme_suggestions_HOOK_alter() for the 'page' hook. In this hook we get the node parameter from \Drupal::routeMatch() and later call $node->bundle(). The node parameter is a string at this point, not the full node object. This results in a PHP error and the merge translations page fails to load.

Steps to reproduce

  1. Install module
  2. Add a hook_theme_suggestions_page_alter() function to your theme
  3. Get the node and call any method on it, e.g. $node_bundle = \Drupal::routeMatch()->getParameter('node')->bundle()
  4. Load the Merge translations page for any node.

Proposed resolution

Upcast the node parameter in the route.

📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇨🇦Canada gregcube

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024