symfony 更改对象操作的 url

发布于 2024-12-21 10:01:25 字数 1154 浏览 2 评论 0原文

我有一个对象操作 approve,我想将其 url 从 /module/ListApprove/action?id=XXX 更改为 /module/:slug/批准。我尝试在 routing.yml 中添加路由,但没有帮助。另外,我在操作中定义了 ecexuteApprove

修改routing.yml

poster_approve:
  url: /poster/:slug/approve
  params: {module: poster, action: approve}

poster:
  class: sfDoctrineRouteCollection
  options:
    model:                Poster
    module:               poster
    prefix_path:          /poster
    column:               slug
    with_wildcard_routes: true

当我手动调用/poster/someslug/approve时,它工作正常。但在管理列表界面的 actions 栏中,approve 的 url 不是 /poster/someslug/approve ,而是 /poster/ListApprove/action?id=12/poster/ListApprove/action?id=12代码>.

之后,我向 generator.yml 添加了一个操作参数,如下所示:

        object_actions:    
          _delete: 
            credentials: delete_poster
          approve:            
            credentials: approve_poster
            action:      approve

但这次唯一的变化是,链接网址变为 /poster/approve/action?id=12。我该如何改变这个?

I have an object action approve and I'd like to change its url from /module/ListApprove/action?id=XXX to /module/:slug/approve. I have tried adding a route in routing.yml but no help. Also, I have ecexuteApprove defined in my action.

modified routing.yml:

poster_approve:
  url: /poster/:slug/approve
  params: {module: poster, action: approve}

poster:
  class: sfDoctrineRouteCollection
  options:
    model:                Poster
    module:               poster
    prefix_path:          /poster
    column:               slug
    with_wildcard_routes: true

when I manually call /poster/someslug/approve, it works fine. But in the admin list interface, in the actions column, the url for approve is not /poster/someslug/approve , instead it is /poster/ListApprove/action?id=12.

After it I added an action parameter to my generator.yml like this:

        object_actions:    
          _delete: 
            credentials: delete_poster
          approve:            
            credentials: approve_poster
            action:      approve

but the only change this time is, the link url becomes /poster/approve/action?id=12. How do I change this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花伊自在美 2024-12-28 10:01:25

你的routing.yml操作是什么样的?您可以添加类似以下内容:

list_approve:
  url:    /someModule/:slug/:id
  param:  { module: someModule, action: approve }

请定义但没有帮助,您遇到了什么问题?

How does your routing.yml action look like? You could add something like:

list_approve:
  url:    /someModule/:slug/:id
  param:  { module: someModule, action: approve }

Please define but no help, what problem are you encountering?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文