如何手动生成到 easyadmin 的路由

how to generate manually a route to easyadmin

我正在为我的网站使用 easyadmin。为了管理一个图片库,我想显示每个图片的缩略图,包裹在 link 中,这会导致实体 Image [=17] 的实际 show 动作=]

画廊的定义如下:

Album:
    class: App\Entity\Album
        list:
            fields:
                - titre
                - images
            show:
                fields:
                    - titre
                    - { property: images, template: admin/field_mosaic.html.twig }

以及我创建的自定义模板:

<div class="gallery m-2">
    {% for image in item.images %}
        <a href="{{ path('easy_admin_bundle') }}?entity={{ link_parameters.entity }}&action={{ link_parameters.action }}&primary_key_name={{ link_parameters.primary_key_name }}&id={{ item.id }}">
            <img class="rounded m-2" src="{{ asset(vich_uploader_asset(image, "imageFile"))|imagine_filter('profile_list') }}" alt="image #{{ loop.index }}">
        </a>
    {% endfor %}
</div>

不幸的是,我不知道 easyadminbundle 的主要路径的名称。我试过 {{ path('admin') }} 无效,routes\easy_admin.yaml 文件中的名称也无效。

我在哪里可以找到它?

10 分钟后,我决定 运行 一个简单的

$php bin/console debug:router

我找到了这个小家伙:

+--------------+------------------------------------------------------------------------------------------+
| Property     | Value                                                                                    |
+--------------+------------------------------------------------------------------------------------------+
| Route Name   | easyadmin                                                                                |
| Path         | /admindatabase/                                                                          |
| Path Regex   | #^/admindatabase/$#sD                                                                    |
| Host         | ANY                                                                                      |
| Host Regex   |                                                                                          |
| Scheme       | ANY                                                                                      |
| Method       | ANY                                                                                      |
| Requirements | NO CUSTOM                                                                                |
| Class        | Symfony\Component\Routing\Route                                                          |
| Defaults     | _controller: EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController::indexAction |
| Options      | compiler_class: Symfony\Component\Routing\RouteCompiler                                  |
+--------------+------------------------------------------------------------------------------------------+

抱歉打扰....