Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/LiveComponent/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
/composer.lock
/phpunit.xml
/.phpunit.result.cache

/var
24 changes: 1 addition & 23 deletions src/LiveComponent/src/Attribute/AsLiveComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,15 @@ public function __construct(
string|bool $route = 'ux_live_component',
string $method = 'post',
int|string $urlReferenceType = UrlGeneratorInterface::ABSOLUTE_PATH,
public bool|int $csrf = true, // @deprecated
) {
if (8 < \func_num_args() || \is_bool($route)) {
trigger_deprecation('symfony/ux-live-component', '2.21', 'Argument "$csrf" of "#[%s]" has no effect anymore and is deprecated.', static::class);
}
if (\is_bool($route)) {
$this->csrf = $route;
$route = $method;
$method = $urlReferenceType;
$urlReferenceType = $csrf;

switch (\func_num_args()) {
case 6: $route = 'ux_live_component';
// no break
case 7: $method = 'post';
// no break
case 8: $urlReferenceType = UrlGeneratorInterface::ABSOLUTE_PATH;
// no break
default:
}
}

parent::__construct($name, $template, $exposePublicProps, $attributesVar);

$this->defaultAction = $defaultAction;
$this->route = $route;
$this->method = strtolower($method);
$this->urlReferenceType = $urlReferenceType;

if (!\in_array($method, ['get', 'post'])) {
if (!\in_array($this->method, ['get', 'post'])) {
throw new \UnexpectedValueException('$method must be either \'get\' or \'post\'.');
}
}
Expand All @@ -91,7 +70,6 @@ public function serviceConfig(): array
return array_merge(parent::serviceConfig(), [
'default_action' => $this->defaultAction,
'live' => true,
'csrf' => $this->csrf,
'route' => $this->route,
'method' => $this->method,
'url_reference_type' => $this->urlReferenceType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ public function onPostMount(PostMountEvent $event): void
return;
}

if (\array_key_exists('defer', $data)) {
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".');
if ($data['defer']) {
$event->addExtraMetadata('loading', 'defer');
}
unset($data['defer']);
}

if (\array_key_exists('loading', $data)) {
// Ignored values: false / null / ''
if ($loading = $data['loading']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,6 @@ public function testLoadingAttributeIsNotExtractedWhenComponentIsNotLive()
$this->assertArrayHasKey('loading', $event->getData());
}

/**
* @group legacy
*/
public function testLoadingAttributeOverrideDeferAttribute()
{
$subscriber = new DeferLiveComponentSubscriber();
$event = $this->createPostMountEvent(['loading' => 'lazy', 'defer' => true]);

$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".');

$subscriber->onPostMount($event);

$this->assertArrayHasKey('loading', $event->getExtraMetadata());
$this->assertSame('lazy', $event->getExtraMetadata()['loading']);
}

/**
* @group legacy
*/
public function testDeferAttributeTriggerDeprecation()
{
$subscriber = new DeferLiveComponentSubscriber();
$event = $this->createPostMountEvent([
'defer' => true,
]);

$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".');

$subscriber->onPostMount($event);
}

public function testLoadingAttributesAreRemoved()
{
$subscriber = new DeferLiveComponentSubscriber();
Expand Down
Loading