📜  linktocrudaction easyadmin 3 (1)

📅  最后修改于: 2023-12-03 14:43:54.062000             🧑  作者: Mango

LinkToCrudAction with EasyAdmin 3

Are you looking for an easy way to link your EasyAdmin 3 actions to a CRUD controller? Look no further than LinkToCrudAction!

What is LinkToCrudAction?

LinkToCrudAction is a Symfony bundle that provides a new action for EasyAdmin 3 that allows you to link to any CRUD controller. This makes it easy to create links from your EasyAdmin 3 pages to CRUD controllers for related entities.

How to Use LinkToCrudAction

To use LinkToCrudAction, simply add it to your Symfony project via composer:

composer require linktocrudaction/easyadmin-bundle

Then, add the action to your EasyAdmin 3 configuration by creating a service for it:

# config/services.yaml

services:
    _defaults:
        autowire: true
        autoconfigure: true

    # ...
    EasyCorp\Bundle\EasyAdminBundle\Field\Configurator\AssociationFieldConfigurator:
        tags:
            - { name: easyadmin.field_configurator }

    # Registering LinkToCrudAction
    LinkToCrudAction\EasyAdminBundle\Action\LinkToCrudAction:
        tags:
            - { name: 'easyadmin.action', priority: -10 }

After adding the service, you can use the LinkToCrud action in your EasyAdmin 3 configuration:

#config/packages/easy_admin.yaml

easy_admin:
    entities:
        Product:
            class: App\Entity\Product
            #...
            list:
                actions:
                    - { name: 'LinkToCrud', label: 'Related Reviews', args: { entityName: 'Review', routeName: 'easyadmin' } }

In this example, we're linking to an entity Review and providing the routeName of easyadmin.

Conclusion

By using LinkToCrudAction, you can easily create links from your EasyAdmin 3 pages to related CRUD controllers. With just a few quick steps, you can set up this bundle and start using the LinkToCrud action in your EasyAdmin 3 configuration. Happy coding!