Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] doc: add example of a custom action #6610

Closed
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
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
Loading