copyRawVariables should support default route parameters

Created on 28 April 2022, over 2 years ago
Updated 8 May 2023, over 1 year ago

This is a replacement issue for   #2743303-22: EntityForm::getEntityFromRouteMatch() does not support route-level parameters .

Problem/Motivation

We recently changed from using _node_add_access which made me realize that _entity_create_access won't take a default parameter.

Steps to reproduce

Add a route that uses a default instead of a path slug.

my.node.add:
  path: '/my/node/add/page'
  defaults:
    node_type: 'page'
    _entity_form: 'node.default'
    _title_callback: '\Drupal\node\Controller\NodeController::addPageTitle'
  requirements:
    _entity_create_access: 'node:{node_type}'
  options:
    _node_operation_route: TRUE
    parameters:
      node_type:
        type: entity:node_type

When you load the page you should get a 403 Access denied.

Proposed resolution

Like larowlan suggested 🐛 copyRawVariables should support default route parameters Fixed , we should make how ParamConversionEnhancer::copyRawVariables and RouteMatch::getParameterNames consistent by giving them the same treatment to defaults.

🐛 Bug report
Status

Fixed

Version

9.5

Component
Routing 

Last updated about 13 hours ago

Created by

🇺🇸United States Tim Bozeman

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