Skip to content

Commit dedcaa6

Browse files
committed
feature #3051 [LiveComponent][UX3] Remove deprecations (smnandre)
This PR was merged into the 3.x branch. Discussion ---------- [LiveComponent][UX3] Remove deprecations | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Docs? | no | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT Commits ------- b928e91 [UX3][LiveComponent] Remove deprecations
2 parents 3e832d8 + b928e91 commit dedcaa6

File tree

4 files changed

+1
-63
lines changed

4 files changed

+1
-63
lines changed

src/LiveComponent/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
/composer.lock
44
/phpunit.xml
55
/.phpunit.result.cache
6-
76
/var

src/LiveComponent/src/Attribute/AsLiveComponent.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,15 @@ public function __construct(
4949
string|bool $route = 'ux_live_component',
5050
string $method = 'post',
5151
int|string $urlReferenceType = UrlGeneratorInterface::ABSOLUTE_PATH,
52-
public bool|int $csrf = true, // @deprecated
5352
) {
54-
if (8 < \func_num_args() || \is_bool($route)) {
55-
trigger_deprecation('symfony/ux-live-component', '2.21', 'Argument "$csrf" of "#[%s]" has no effect anymore and is deprecated.', static::class);
56-
}
57-
if (\is_bool($route)) {
58-
$this->csrf = $route;
59-
$route = $method;
60-
$method = $urlReferenceType;
61-
$urlReferenceType = $csrf;
62-
63-
switch (\func_num_args()) {
64-
case 6: $route = 'ux_live_component';
65-
// no break
66-
case 7: $method = 'post';
67-
// no break
68-
case 8: $urlReferenceType = UrlGeneratorInterface::ABSOLUTE_PATH;
69-
// no break
70-
default:
71-
}
72-
}
73-
7453
parent::__construct($name, $template, $exposePublicProps, $attributesVar);
7554

7655
$this->defaultAction = $defaultAction;
7756
$this->route = $route;
7857
$this->method = strtolower($method);
7958
$this->urlReferenceType = $urlReferenceType;
8059

81-
if (!\in_array($method, ['get', 'post'])) {
60+
if (!\in_array($this->method, ['get', 'post'])) {
8261
throw new \UnexpectedValueException('$method must be either \'get\' or \'post\'.');
8362
}
8463
}
@@ -91,7 +70,6 @@ public function serviceConfig(): array
9170
return array_merge(parent::serviceConfig(), [
9271
'default_action' => $this->defaultAction,
9372
'live' => true,
94-
'csrf' => $this->csrf,
9573
'route' => $this->route,
9674
'method' => $this->method,
9775
'url_reference_type' => $this->urlReferenceType,

src/LiveComponent/src/EventListener/DeferLiveComponentSubscriber.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ public function onPostMount(PostMountEvent $event): void
3434
return;
3535
}
3636

37-
if (\array_key_exists('defer', $data)) {
38-
trigger_deprecation('symfony/ux-live-component', '2.17', 'The "defer" attribute is deprecated and will be removed in 3.0. Use the "loading" attribute instead set to the value "defer".');
39-
if ($data['defer']) {
40-
$event->addExtraMetadata('loading', 'defer');
41-
}
42-
unset($data['defer']);
43-
}
44-
4537
if (\array_key_exists('loading', $data)) {
4638
// Ignored values: false / null / ''
4739
if ($loading = $data['loading']) {

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,6 @@ public function testLoadingAttributeIsNotExtractedWhenComponentIsNotLive()
4949
$this->assertArrayHasKey('loading', $event->getData());
5050
}
5151

52-
/**
53-
* @group legacy
54-
*/
55-
public function testLoadingAttributeOverrideDeferAttribute()
56-
{
57-
$subscriber = new DeferLiveComponentSubscriber();
58-
$event = $this->createPostMountEvent(['loading' => 'lazy', 'defer' => true]);
59-
60-
$this->expectDeprecation('Since symfony/ux-live-component 2.17: The "defer" attribute is deprecated and will be removed in 3.0. Use the "loading" attribute instead set to the value "defer".');
61-
62-
$subscriber->onPostMount($event);
63-
64-
$this->assertArrayHasKey('loading', $event->getExtraMetadata());
65-
$this->assertSame('lazy', $event->getExtraMetadata()['loading']);
66-
}
67-
68-
/**
69-
* @group legacy
70-
*/
71-
public function testDeferAttributeTriggerDeprecation()
72-
{
73-
$subscriber = new DeferLiveComponentSubscriber();
74-
$event = $this->createPostMountEvent([
75-
'defer' => true,
76-
]);
77-
78-
$this->expectDeprecation('Since symfony/ux-live-component 2.17: The "defer" attribute is deprecated and will be removed in 3.0. Use the "loading" attribute instead set to the value "defer".');
79-
80-
$subscriber->onPostMount($event);
81-
}
82-
8352
public function testLoadingAttributesAreRemoved()
8453
{
8554
$subscriber = new DeferLiveComponentSubscriber();

0 commit comments

Comments
 (0)