-
-
Notifications
You must be signed in to change notification settings - Fork 391
[Live] Control the type of generated URLs #1398
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
Conversation
|
Seems to me a very specific use case.. could it be handled with router configuration ? |
| function (ChildDefinition $definition, AsLiveComponent $attribute) { | ||
| $definition | ||
| ->addTag('twig.component', array_filter($attribute->serviceConfig())) | ||
| ->addTag('twig.component', array_filter($attribute->serviceConfig(), static fn ($v) => null !== $v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to this PR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, it does not work. It's a separate commit, so it can be cherry-picked as a bugfix or it can be moved to its own PR if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an error without it? I actually can't remember why we have that array_filter() at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the array_filter it breaks the compiler pass in TwigComponent...
| if (!\array_key_exists('key', $tag)) { |
and other places where null is not checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but would that break things now that you allow empty strings ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not, all tests are green, but I can add '' !== $v too, if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I added back filtering out empty strings too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man it took me so much time to understand i'm sorry ..
I suggest that we handle that in another PR, as it's clearly not in LiveComponent that we should handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me a very specific use case.. could it be handled with router configuration ?
IDK maybe.. what do you have in mind?
If you suggesting to use the host parameter it doesn't work, because from Symfony's point of view the host is the same as the request comes in to.
| function (ChildDefinition $definition, AsLiveComponent $attribute) { | ||
| $definition | ||
| ->addTag('twig.component', array_filter($attribute->serviceConfig())) | ||
| ->addTag('twig.component', array_filter($attribute->serviceConfig(), static fn ($v) => null !== $v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, it does not work. It's a separate commit, so it can be cherry-picked as a bugfix or it can be moved to its own PR if needed.
weaverryan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks sensible to me!
| function (ChildDefinition $definition, AsLiveComponent $attribute) { | ||
| $definition | ||
| ->addTag('twig.component', array_filter($attribute->serviceConfig())) | ||
| ->addTag('twig.component', array_filter($attribute->serviceConfig(), static fn ($v) => null !== $v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an error without it? I actually can't remember why we have that array_filter() at all
|
Wait, so you'll POST from domainA.com to domainB.com ? Should this be on a component - per - component basis... or a config wide one (that seem more logical to me) ? |
As the route can be configured on the component level, for me it is logical to do the same with the URL generated for that route. |
Yes i mean, should this be possible to config it on an app-level too, as the route can be configured there for all components ? Last thing, is there any implication/effect with the "liveQuery" thing ? |
Ah, I see. That would mean we need to introduce configuration for the live component and add a config entry for it, e.g. something like live_component:
default_url_reference_type: 'absolute_path' # support strings and UrlGeneratorInterface consts too -> map strings back to constsread the configuration and use this as the default value for the metadata (the default in
I'm not sure, I'm not familiar with that, but I took a look at the PR and I think using the browser's history api and getting query string values from the request should not be affected by this. |
|
Could you add a test with an action (just to be sure everything work with in JS and in the request handling ? (and that way we'd have a regression test later on this) |
I just added a test for that (but without js, for that we would need to setup panther, I think). |
c60e5bf to
69ef030
Compare
|
I think this is ready. Can we merge it in this form or it needs more work? |
69ef030 to
7e91f1f
Compare
|
Thanks Gábor! |
Add a way to generate absolute URLs for live components.
My use case is that I embed a page with live components
into a site on a different host, so I need absolute URLs
for the components to work properly.