Skip to content

Commit 465cc7e

Browse files
committed
returns
1 parent 9a5b9cf commit 465cc7e

File tree

9 files changed

+23
-21
lines changed

9 files changed

+23
-21
lines changed

src/LiveComponent/assets/dist/Backend/BackendResponse.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export default class {
44
private liveUrl;
55
constructor(response: Response);
66
getBody(): Promise<string>;
7-
getLiveUrl(): Promise<string | null>;
7+
getLiveUrl(): string | null;
88
}

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ class BackendResponse {
112112
}
113113
return this.body;
114114
}
115-
async getLiveUrl() {
115+
getLiveUrl() {
116116
if (undefined === this.liveUrl) {
117-
this.liveUrl = await this.response.headers.get('X-Live-Url');
117+
this.liveUrl = this.response.headers.get('X-Live-Url');
118118
}
119119
return this.liveUrl;
120120
}
@@ -2144,7 +2144,7 @@ class Component {
21442144
return response;
21452145
}
21462146
this.processRerender(html, backendResponse);
2147-
const liveUrl = await backendResponse.getLiveUrl();
2147+
const liveUrl = backendResponse.getLiveUrl();
21482148
if (liveUrl) {
21492149
history.replaceState(history.state, '', new URL(liveUrl + window.location.hash, window.location.origin));
21502150
}

src/LiveComponent/assets/src/Backend/BackendResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export default class {
1515
return this.body;
1616
}
1717

18-
async getLiveUrl(): Promise<string | null> {
18+
getLiveUrl(): string | null {
1919
if (undefined === this.liveUrl) {
20-
this.liveUrl = await this.response.headers.get('X-Live-Url');
20+
this.liveUrl = this.response.headers.get('X-Live-Url');
2121
}
2222

2323
return this.liveUrl;

src/LiveComponent/assets/src/Component/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export default class Component {
328328
}
329329

330330
this.processRerender(html, backendResponse);
331-
const liveUrl = await backendResponse.getLiveUrl();
331+
const liveUrl = backendResponse.getLiveUrl();
332332
if (liveUrl) {
333333
history.replaceState(
334334
history.state,

src/LiveComponent/doc/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,11 +2680,11 @@ The ``query`` value will appear in the URL like ``/search?query=my+important+que
26802680
Map the parameter to path instead of query
26812681
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26822682

2683-
.. versionadded:: 2.27
2683+
.. versionadded:: 2.28
26842684

2685-
The ``mapPath`` option was added in LiveComponents 2.27.
2685+
The ``mapPath`` option was added in LiveComponents 2.28.
26862686

2687-
Instead of setting the LiveProp as a query parameter, you can set it as route parameter.
2687+
Instead of setting the ``LiveProp`` as a query parameter, you can set it as route parameter.
26882688
definition::
26892689

26902690
// ...
@@ -2700,7 +2700,7 @@ definition::
27002700
}
27012701

27022702

2703-
The if the symfony route is defined like this::
2703+
If the symfony route is defined like this::
27042704

27052705
// src/Controller/NodeController.php
27062706
// ...
@@ -2713,7 +2713,7 @@ The if the symfony route is defined like this::
27132713

27142714
Then the ``id`` value will appear in the URL like ``https://my.domain/node/my-node-id``.
27152715

2716-
If the route parameter name is different from the LiveProp name, the ``as`` option can be used to map the LiveProp.
2716+
If the route parameter name is different from the LiveProp name, the ``as`` option can be used to map the ``LiveProp``.
27172717

27182718
If the route parameter is not defined, the ``mapPath`` option will be ignored and the LiveProp value will fallback to a query parameter.
27192719

src/LiveComponent/src/EventListener/LiveComponentSubscriber.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ public function onKernelView(ViewEvent $event): void
258258
$mountedComponent = $request->attributes->get('_mounted_component');
259259
if (!$request->attributes->get('_component_default_action', false)) {
260260
// On custom action, props may be updated by the server side
261-
// @todo discuss name responseProps
262-
// @todo maybe always set in, including default action and use only this, ignoring `props` and `updated` for UrlFactory ?
263261
$liveRequestData = $request->attributes->get('_live_request_data');
264262
$liveRequestData['responseProps'] = (array) $mountedComponent->getComponent();
265263
$request->attributes->set('_live_request_data', $liveRequestData);

src/LiveComponent/src/Util/UrlFactory.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,19 @@ private function replaceQueryString($url, array $props): string
7474
$queryString;
7575
}
7676

77-
// Keep the query parameters of the previous request
77+
/**
78+
* Keep the query parameters of the previous request
79+
*/
7880
private function getPreviousQueryParameters(string $query): array
7981
{
8082
parse_str($query, $previousQueryParams);
8183

8284
return $previousQueryParams;
8385
}
8486

85-
// Symfony router will set props in query if they do not match route parameter
87+
/**
88+
* Symfony router will set props in query if they do not match route parameter
89+
*/
8690
private function getRemnantProps(string $newUrl): array
8791
{
8892
parse_str(parse_url($newUrl)['query'] ?? '', $remnantQueryParams);

src/LiveComponent/tests/Unit/EventListener/LiveUrlSubscriberTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testDoNothing(
7272
$this->assertNull($response->headers->get('X-Live-Url'));
7373
}
7474

75-
public function getData(): iterable
75+
public static function provideTestUrlFactoryReceivesPathAndQuertyPropsFromRequestData(): iterable
7676
{
7777
yield 'prop_without_matching_property' => [
7878
'liveRequestData' => [
@@ -137,9 +137,9 @@ public function getData(): iterable
137137
}
138138

139139
/**
140-
* @dataProvider getData
140+
* @dataProvider provideTestUrlFactoryReceivesPathAndQuertyPropsFromRequestData
141141
*/
142-
public function testProps(
142+
public function testUrlFactoryReceivesPathAndQuertyPropsFromRequestData(
143143
array $liveRequestData,
144144
array $expectedPathProps = [],
145145
array $expectedQueryProps = [],

src/LiveComponent/tests/Unit/Util/UrlFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class UrlFactoryTest extends TestCase
2121
{
22-
public function getData(): \Generator
22+
public static function provideTestCreate(): \Generator
2323
{
2424
yield 'keep_default_url' => [];
2525

@@ -104,7 +104,7 @@ public function getData(): \Generator
104104
}
105105

106106
/**
107-
* @dataProvider getData
107+
* @dataProvider provideTestCreate
108108
*/
109109
public function testCreate(
110110
array $input = [],

0 commit comments

Comments
 (0)