Skip to content

Conversation

@absumo
Copy link
Contributor

@absumo absumo commented Jan 22, 2026

Fix removed request->get method.
Was removed in symfony 8.0

Summary by Sourcery

Bug Fixes:

  • Fix route lookup in DefaultMenuListener by reading the current route from the request attributes instead of the removed Request::get() method.

Was removed in symfony 8.0
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 22, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Update Symfony request access to be compatible with Symfony 8.0 by replacing deprecated/removed Request::get() usage with attribute access for the current route name.

Sequence diagram for DefaultMenuListener route retrieval change

sequenceDiagram
    actor User
    participant Framework as HttpKernel
    participant RequestStack
    participant Request
    participant DefaultMenuListener
    participant ItemInterface as MenuItem

    User->>Framework: HTTP request
    Framework->>RequestStack: getCurrentRequest()
    RequestStack-->>Framework: Request
    Framework->>DefaultMenuListener: enableChildRoutes(MenuItem, prefix)
    DefaultMenuListener->>RequestStack: getCurrentRequest()
    RequestStack-->>DefaultMenuListener: Request
    DefaultMenuListener->>Request: attributes.get(_route)
    Request-->>DefaultMenuListener: routeName
    DefaultMenuListener->>DefaultMenuListener: str_contains(routeName, prefix)
    alt routeName contains prefix
        DefaultMenuListener->>MenuItem: setExtra(routes = [{route: routeName}])
    end
Loading

File-Level Changes

Change Details Files
Switch route name retrieval from Request::get() to Request attribute access for Symfony 8 compatibility.
  • Retrieve the current route name via $request->attributes->get('_route') instead of $request->get('_route') in the menu listener condition.
  • Update the route value passed into the 'routes' extra of the menu item to also use $request->attributes->get('_route').
src/EventListener/DefaultMenuListener.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider guarding against a null current request or missing _route attribute before calling str_contains, since RequestStack::getCurrentRequest() and Request::attributes->get() can both return null and would cause a TypeError in str_contains.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding against a null current request or missing `_route` attribute before calling `str_contains`, since `RequestStack::getCurrentRequest()` and `Request::attributes->get()` can both return null and would cause a TypeError in `str_contains`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants