Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/LiveComponent/src/Twig/LiveComponentRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public function renderLiveAttributes(Environment $env, object $component, string
);
}

public function getComponentUrl(object $component, string $name = null): string
public function getComponentUrl(string $name, array $props = []): string
{
$data = $this->hydrator->dehydrate($component);
$params = ['component' => $this->nameFor($component, $name)] + $data;
$component = $this->factory->create($name, $props);
$params = ['component' => $name] + $this->hydrator->dehydrate($component);

return $this->urlGenerator->generate('live_component', $params);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ component_url('component1', { prop1: null, prop2: date }) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\UX\LiveComponent\Tests\Integration;

use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\UX\LiveComponent\Tests\ContainerBC;

/**
* @author Kevin Bond <[email protected]>
*/
final class LiveComponentExtensionTest extends KernelTestCase
{
use ContainerBC;

public function testGetComponentUrl(): void
{
$rendered = self::getContainer()->get('twig')->render('component_url.html.twig', [
'date' => new \DateTime('2022-10-06-0'),
]);

$this->assertStringContainsString('/_components/component1?prop2=2022-10-06T00:00:00', $rendered);
$this->assertStringContainsString('_checksum=', $rendered);
}
}