Skip to content

[LiveComponent] Add setRouteLocale in TestLiveComponent #2124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

smnandre
Copy link
Member

@smnandre smnandre commented Sep 2, 2024

Q A
Bug fix? no
New feature? yes
Issues Fix #1565
License MIT

The live_component route can be localized. It then requires the {_locale} the parameter to be defined.

# config/routes/ux_live_component.yaml
  live_component:
      resource: '@LiveComponentBundle/config/routes.php'
-     prefix: /_components
+     prefix: /{_locale}/_components

This PR adds a setRouteLocale method in TestLiveComponent to help in this situation.

$testComponent = $this->createLiveComponent('Acme:Foo');
$testComponent->setRouteLocale('de');

// $testComponent is rendered with the 'de' locale

Thank you @javiereguiluz for the idea and your help :)

@carsonbot carsonbot added Feature New Feature LiveComponent Status: Needs Review Needs to be reviewed labels Sep 2, 2024
@smnandre smnandre added the DX label Sep 2, 2024
@smnandre smnandre requested a review from kbond September 2, 2024 20:19
Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

Thanks!

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Sep 3, 2024
@javiereguiluz javiereguiluz force-pushed the live/set-route-locale-test-helper branch from 685f5de to 2f00e3f Compare September 6, 2024 08:18
@javiereguiluz
Copy link
Member

Thank you Simon.

@javiereguiluz javiereguiluz merged commit f70775f into symfony:2.x Sep 6, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Feature New Feature LiveComponent Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LiveComponent] Test helper doesn't work with localized components
4 participants