Skip to content

421 seo#235

Draft
tijsverkoyen wants to merge 5 commits into
masterfrom
421-seo
Draft

421 seo#235
tijsverkoyen wants to merge 5 commits into
masterfrom
421-seo

Conversation

@tijsverkoyen

@tijsverkoyen tijsverkoyen commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary by Sourcery

Align breadcrumb and title handling with controller arguments and improve SEO-related markup and documentation.

Enhancements:

  • Refactor breadcrumb listener to use ControllerArgumentsEvent, rely on named controller arguments instead of Doctrine entity lookups, and simplify route/controller resolution.
  • Refactor title listener to resolve the active controller method directly, work with named arguments, and remove MapEntity/EntityManager dependencies.
  • Update base Twig layouts to inline full HTML structures with dynamic <title>, CSP nonce handling, and social/SEO meta tags instead of including a shared head partial.
  • Clarify and modernize breadcrumb and title documentation to describe current attribute behaviour, dynamic values, parent chaining, and page title resolution order.

Documentation:

  • Rewrite breadcrumb usage documentation with clearer examples, dynamic title support, parent route chaining, and translation behaviour.
  • Expand title documentation to cover resolution order, configuration of fallback.site_title, dynamic titles, parent routes, and direct PageTitle service usage.

@sourcery-ai

sourcery-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors breadcrumb and title listeners to use controller argument-based resolution instead of Doctrine/MapEntity, updates docs to match the new behavior, switches listeners to the kernel.controller_arguments event, and inlines the HTML head section into all base templates for better SEO control and CSP integration.

Sequence diagram for controller_arguments-based breadcrumb and title resolution

sequenceDiagram
    actor User
    participant HttpKernel
    participant BreadcrumbListener
    participant TitleListener
    participant BreadcrumbTrail
    participant PageTitle
    participant Fallbacks
    participant TwigTemplate

    User ->> HttpKernel: HTTP request
    HttpKernel ->> BreadcrumbListener: onKernelControllerArguments(ControllerArgumentsEvent)
    BreadcrumbListener ->> BreadcrumbTrail: reset() [main request]
    BreadcrumbListener ->> BreadcrumbListener: processAttributeFromMethod(method, class, namedArguments, request, route)
    BreadcrumbListener ->> BreadcrumbListener: generateBreadcrumb(breadcrumbAttribute, namedArguments, request)
    BreadcrumbListener ->> BreadcrumbListener: resolveRouteParameters(breadcrumbAttribute, namedArguments, request)
    BreadcrumbListener ->> BreadcrumbTrail: add(Breadcrumb)

    HttpKernel ->> TitleListener: onKernelControllerArguments(ControllerArgumentsEvent)
    TitleListener ->> TitleListener: resolveMethod(controller)
    TitleListener ->> TitleListener: processTitle(titleString, namedArguments)
    TitleListener ->> TitleListener: getTitleFromParent(Route, namedArguments)
    TitleListener ->> Fallbacks: get("site_title")
    Fallbacks -->> TitleListener: site_title
    TitleListener ->> PageTitle: setTitle(resolvedTitle + " - " + site_title)

    HttpKernel -->> TwigTemplate: render(base.html.twig)
    TwigTemplate ->> PageTitle: __toString()
    PageTitle -->> TwigTemplate: page_title
    TwigTemplate ->> TwigTemplate: <title>{{ page_title }}</title>
Loading

File-Level Changes

Change Details Files
Refactor BreadcrumbListener to resolve breadcrumbs from controller named arguments and request instead of Doctrine entity lookups and generic method scanning.
  • Change listener hook from onKernelController(KernelEvent) to onKernelControllerArguments(ControllerArgumentsEvent) and update service tag accordingly.
  • Derive the current ReflectionMethod from the resolved controller (including __invoke) instead of iterating all public methods on the controller class.
  • Remove EntityManager and MapEntity usage; resolve breadcrumb title and route parameters directly from the ControllerArgumentsEvent named arguments array.
  • Update generateBreadcrumb, addBreadcrumbsForParent, resolveRouteParameters, and getRouteInformation to pass named arguments and Request explicitly and to compute controller/method names more robustly, including invokable controllers.
  • Simplify error messages and entity lookup failures to reference argument names rather than IDs and class names.
src/EventListener/BreadcrumbListener.php
config/services.php
Simplify TitleListener to use controller named arguments and drop MapEntity/Doctrine resolution, while keeping parent title chain resolution.
  • Change listener hook from onKernelController to onKernelControllerArguments and adjust typehints accordingly.
  • Introduce resolveMethod() helper to get the correct ReflectionMethod for array and invokable controllers, returning null for unsupported callables.
  • Remove EntityManager and MapEntity logic; take parameters directly from ControllerArgumentsEvent::getNamedArguments().
  • Keep processTitle and parent-route resolution, but update getRouteInformation to separate controller class and method similar to BreadcrumbListener.
  • Ensure non-extending Title attributes set the title directly without appending fallbacks site title.
src/EventListener/TitleListener.php
config/services.php
Rewrite breadcrumb and title documentation to describe the new argument-based behavior and clarify limitations and examples.
  • Rewrite breadcrumb.md to focus on controller attributes, named-argument based dynamic titles, parent route chaining, translation usage, and limitations around scalars vs objects.
  • Rewrite title.md to describe resolution order, configuration of fallback.site_title, dynamic titles from arguments, parent chains, extend=false semantics, and direct PageTitle usage in services and Twig.
docs/development/breadcrumb.md
docs/development/title.md
Inline the HTML section into all layout templates, removing the shared head.html.twig partial, to expose proper <title> and SEO meta tags and integrate CSP nonces.
  • Replace the head block includes in base, base_no_sidebar, empty, user, and base_error templates with full HTML skeletons including <!doctype>, , , and <title> using page_title by default.
  • Add meta viewport, CSP nonce generation, author meta tag, stylesheet link(s), importmap javascripts with nonce, icon and favicon links, Windows tile meta tags, Open Graph image, and Twitter card metadata to each template.
  • Expose overridable Twig blocks (title, meta, stylesheets, javascripts, icons, favicon, windows_tile, og, twitter, end_head) in each base template.
  • Remove the now-unused @SumoCodersFrameworkCore/head.html.twig partial.
templates/base.html.twig
templates/base_no_sidebar.html.twig
templates/empty.html.twig
templates/user.html.twig
templates/base_error.html.twig
templates/head.html.twig

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

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.

1 participant