Skip to content

Commit ea57558

Browse files
committed
Use public readonly in UrlMapping
1 parent c284a63 commit ea57558

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

src/LiveComponent/src/Metadata/UrlMapping.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ public function __construct(
2222
/**
2323
* The name of the prop that appears in the URL. If null, the LiveProp's field name is used.
2424
*/
25-
private ?string $as = null,
25+
public readonly ?string $as = null,
2626
) {
2727
}
28-
29-
public function getAs(): ?string
30-
{
31-
return $this->as;
32-
}
3328
}

src/LiveComponent/src/Util/LiveControllerAttributesCreator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function attributesForRendering(MountedComponent $mounted, ComponentMetad
108108
foreach ($liveMetadata->getAllLivePropsMetadata($mounted->getComponent()) as $livePropMetadata) {
109109
if ($urlMapping = $livePropMetadata->urlMapping()) {
110110
$frontendName = $livePropMetadata->calculateFieldName($mounted->getComponent(), $livePropMetadata->getName());
111-
$mappings[$frontendName] = ['name' => $urlMapping->getAs() ?? $frontendName];
111+
$mappings[$frontendName] = ['name' => $urlMapping->as ?? $frontendName];
112112
}
113113
}
114114
$attributesCollection->setQueryUrlMapping($mappings);

src/LiveComponent/src/Util/QueryStringPropsExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function extract(Request $request, LiveComponentMetadata $metadata, objec
4343
foreach ($metadata->getAllLivePropsMetadata($component) as $livePropMetadata) {
4444
if ($queryMapping = $livePropMetadata->urlMapping()) {
4545
$frontendName = $livePropMetadata->calculateFieldName($component, $livePropMetadata->getName());
46-
if (null !== ($value = $query[$queryMapping->getAs() ?? $frontendName] ?? null)) {
46+
if (null !== ($value = $query[$queryMapping->as ?? $frontendName] ?? null)) {
4747
if ('' === $value && null !== $livePropMetadata->getType() && (!$livePropMetadata->isBuiltIn() || 'array' === $livePropMetadata->getType())) {
4848
// Cast empty string to empty array for objects and arrays
4949
$value = [];

0 commit comments

Comments
 (0)