Skip to content

Commit 93dfb74

Browse files
committed
Merge branch '2.x' into 3.x
* 2.x: Fix highest jobs with Doctrine ^3.0 [LiveComponent] Fix new URL generation when using `LiveProp` with custom `fieldName` # Conflicts: # src/LiveComponent/composer.json # src/Turbo/composer.json
2 parents bd3c7b9 + 8bdfff0 commit 93dfb74

File tree

7 files changed

+58
-4
lines changed

7 files changed

+58
-4
lines changed

src/LiveComponent/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
"twig/twig": "^3.10.3"
3636
},
3737
"require-dev": {
38-
"doctrine/annotations": "^1.0",
38+
"doctrine/annotations": "^1.0|^2.0",
3939
"doctrine/collections": "^1.6.8|^2.0",
4040
"doctrine/doctrine-bundle": "^2.14",
41-
"doctrine/orm": "^2.9.4",
41+
"doctrine/orm": "^2.9.4|^3.0",
4242
"doctrine/persistence": "^2.5.2|^3.0",
4343
"phpdocumentor/reflection-docblock": "5.x-dev",
4444
"symfony/dependency-injection": "^6.4|^7.0|^8.0",

src/LiveComponent/src/Metadata/LiveComponentMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getAllUrlMappings(object $component): array
7575

7676
foreach ($this->getAllLivePropsMetadata($component) as $livePropMetadata) {
7777
if ($livePropMetadata->urlMapping()) {
78-
$urlMappings[$livePropMetadata->getName()] = $livePropMetadata->urlMapping();
78+
$urlMappings[$livePropMetadata->calculateFieldName($component, $livePropMetadata->getName())] = $livePropMetadata->urlMapping();
7979
}
8080
}
8181

src/LiveComponent/tests/Fixtures/Component/ComponentWithUrlBoundProps.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ class ComponentWithUrlBoundProps
3333
#[LiveProp(url: true)]
3434
public array $arrayProp = [];
3535

36+
#[LiveProp(url: new UrlMapping(as: 'arr_alias'))]
37+
public array $arrayPropAlias = [];
38+
39+
#[LiveProp(writable: true, fieldName: 'getArrayFieldName()', url: true)]
40+
public array $arrayPropFieldName = [];
41+
3642
#[LiveProp]
3743
public ?string $unboundProp = null;
3844

@@ -113,4 +119,9 @@ public function updateLiveProp(#[LiveArg] string $propName, #[LiveArg] mixed $pr
113119

114120
$this->{$propName} = $propValue;
115121
}
122+
123+
public function getArrayFieldName(): string
124+
{
125+
return 'arr_field_name';
126+
}
116127
}

src/LiveComponent/tests/Functional/EventListener/AddLiveAttributesSubscriberTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public function testQueryStringMappingAttribute()
144144
'objectPropWithSerializerForHydration' => ['name' => 'objectPropWithSerializerForHydration'],
145145
'propertyWithModifierAndAlias' => ['name' => 'alias_p'],
146146
'pathPropForAnotherController' => ['name' => 'pathPropForAnotherController'],
147+
'arrayPropAlias' => ['name' => 'arr_alias'],
148+
'arr_field_name' => ['name' => 'arr_field_name'],
147149
];
148150

149151
$this->assertEquals($expected, $queryMapping);

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function getTestData(): iterable
118118
'propValue' => 'bar',
119119
],
120120
];
121+
121122
yield 'Changes in prop, with two path params but only one prop' => [
122123
'previousLocation' => '/route_with_two_path_params_but_one_prop/foo/30',
123124
'expectedLocation' => '/route_with_two_path_params_but_one_prop/bar/30',
@@ -140,6 +141,42 @@ public function getTestData(): iterable
140141
],
141142
];
142143

144+
yield 'Change in query (array)' => [
145+
'previousLocation' => '/route_with_prop/foo',
146+
'expectedLocation' => '/route_with_prop/foo?arrayProp%5B0%5D=hello&arrayProp%5B1%5D=world',
147+
'initialComponentData' => [
148+
'pathProp' => 'foo',
149+
],
150+
'args' => [
151+
'propName' => 'arrayProp',
152+
'propValue' => ['hello', 'world'],
153+
],
154+
];
155+
156+
yield 'Change in query (array & alias)' => [
157+
'previousLocation' => '/route_with_prop/foo',
158+
'expectedLocation' => '/route_with_prop/foo?arr_alias%5B0%5D=hello&arr_alias%5B1%5D=world',
159+
'initialComponentData' => [
160+
'pathProp' => 'foo',
161+
],
162+
'args' => [
163+
'propName' => 'arrayPropAlias',
164+
'propValue' => ['hello', 'world'],
165+
],
166+
];
167+
168+
yield 'Change in query (array & field name)' => [
169+
'previousLocation' => '/route_with_prop/foo',
170+
'expectedLocation' => '/route_with_prop/foo?arr_field_name%5B0%5D=hello&arr_field_name%5B1%5D=world',
171+
'initialComponentData' => [
172+
'pathProp' => 'foo',
173+
],
174+
'args' => [
175+
'propName' => 'arrayPropFieldName',
176+
'propValue' => ['hello', 'world'],
177+
],
178+
];
179+
143180
yield 'Changes in props and query' => [
144181
'previousLocation' => '/route_with_prop/foo',
145182
'expectedLocation' => '/route_with_prop/baz?q=foo+bar',

src/Turbo/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"require-dev": {
4141
"doctrine/doctrine-bundle": "^2.14",
42-
"doctrine/orm": "^2.8 | 3.0",
42+
"doctrine/orm": "^2.8|^3.0",
4343
"phpstan/phpstan": "^2.1.17",
4444
"symfony/asset-mapper": "^6.4|^7.0|^8.0",
4545
"symfony/debug-bundle": "^6.4|^7.0|^8.0",

src/Turbo/tests/app/Kernel.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ protected function configureContainer(ContainerConfigurator $container): void
106106
if (version_compare($doctrineBundleVersion, '2.9.0', '>=')) {
107107
$doctrineConfig['orm']['report_fields_where_declared'] = true;
108108
}
109+
110+
if (\PHP_VERSION_ID >= 80400 && version_compare($doctrineBundleVersion, '2.15.0', '>=')) {
111+
$doctrineConfig['orm']['enable_native_lazy_objects'] = true;
112+
}
109113
}
110114

111115
$container

0 commit comments

Comments
 (0)