Skip to content

Commit

Permalink
doc: add example of a custom action
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Dec 1, 2024
1 parent 80334e2 commit af3d46a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions doc/actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ The following example shows all kinds of actions in practice::
use App\Entity\Order;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use Symfony\Component\HttpFoundation\Response;

class OrderCrudController extends AbstractCrudController
{
Expand Down Expand Up @@ -354,11 +356,14 @@ The following example shows all kinds of actions in practice::
;
}

public function renderInvoice(AdminContext $context)
public function renderInvoice(AdminContext $context): Response
{
$order = $context->getEntity()->getInstance();

// add your logic here...
// add your logic here, e.g. by using a Twig template...

// this example shows the id of the entity
return new Response((string) $order->getId());
}
}

Expand Down

0 comments on commit af3d46a

Please sign in to comment.