Skip to content

Commit

Permalink
keep only the necessary code to illustrate the LiveAction
Browse files Browse the repository at this point in the history
  • Loading branch information
romain committed Jan 22, 2025
1 parent b4b3a53 commit 99d3d21
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/LiveComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1335,23 +1335,12 @@ Currently, Live Components do not natively support returning file responses dire

Create a LiveAction that generates the URL for the file download and returns a `RedirectResponse`::

use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\UX\LiveComponent\Attribute\LiveAction;

// ...

class MyDownloadButton
{
// ...

#[LiveAction]
public function initiateDownload(UrlGeneratorInterface $urlGenerator): RedirectResponse
{
$url = $urlGenerator->generate('app_file_download');
return new RedirectResponse($url);
}
}

.. code-block:: html+twig

Expand Down Expand Up @@ -3802,7 +3791,7 @@ uses Symfony's test client to render and make requests to your components::
// authenticate a user ($user is instance of UserInterface)
$testComponent->actingAs($user);

// set the '_locale' route parameter (if the component route is localized)
// set the '_locale' route parameter (if the component route is localized)
$testComponent->setRouteLocale('fr');

// customize the test client
Expand Down

0 comments on commit 99d3d21

Please sign in to comment.