无法为命名路由“sg_calendar_update_xhr_event”生成URL

时间:2013-09-04 09:12:43

标签: symfony calendar bundle

我最近在Symfony安装了 SgCalendarBundle,,首先我创建了sg_calendar的路径:

//src MyBundle/config/routing.yml
sg_calendar:
    pattern: /calendar
    defaults: { _controller: SgCalendarBundle:Calendar:index }

但是当我用标签

执行我的页面时
<a class="brand" href="{{ path('sg_calendar') }}">SgCalendarBundle</a>

我在symfony中收到以下错误:Unable to generate a URL for the named route "sg_calendar_update_xhr_event" as such route does not exist. 500 Internal Server Error - RouteNotFoundException

2 个答案:

答案 0 :(得分:3)

需要将注释路由导入routing.yml:

# app/config/routing.yml

# SgRruleBundle
sg_rrule:
    resource: "@SgRruleBundle/Controller/"
    type:     annotation
    prefix:   /

# SgCalendarBundle
sg_calendar:
    resource: "@SgCalendarBundle/Controller/"
    type:     annotation
    prefix:   /

此文档问题已修复:https://github.com/stwe/CalendarBundle/issues/1

答案 1 :(得分:0)

最后,我自己得到了解决方案。 您只需要按照自己的方式路由所有路线:

   //app/config/routing.yml

 sg_calendar:
    path: /calendar
    defaults: { _controller: SgCalendarBundle:Calendar:index }

sg_calendar_create_event:
     path: /calendar/event/new
     defaults: { _controller: SgCalendarBundle:Event:new }

sg_calendar_create_calendar:
     path: /calendar/create
     defaults: { _controller: SgCalendarBundle:Calendar:get }

sg_calendar_update_xhr_event:
     path: /calendar/event/update
     defaults: { _controller: SgCalendarBundle:Event:update }

sg_calendar_new_calendar:
     path: /calendar/new
     defaults: { _controller: SgCalendarBundle:Calendar:new }

sg_calendar_new_event:
     path: /calendar/event/new
     defaults: { _controller: SgCalendarBundle:Event:new }

sg_calendar_get_calendar:
     path: /calendar/{id}/show
     defaults: { _controller: SgCalendarBundle:Calendar:get }

sg_calendar_edit_calendar:
     path: /calendar/{id}/edit
     defaults: { _controller: SgCalendarBundle:Calendar:edit }

sg_calendar_remove_calendar:
     path: /calendar/{id}/remove
     defaults: { _controller: SgCalendarBundle:Calendar:remove }

sg_calendar_get_xhr_events:
     path: /calendar/event/{id}/show
     defaults: { _controller: SgCalendarBundle:Event:get }

sg_calendar_update_calendar:
     path: /calendar/{id}/update
     defaults: { _controller: SgCalendarBundle:Calendar:update }