我有一个管理商店位置的应用程序。我们当前的路线使用/location/{postalCode}
路线模式。
该站点的先前版本允许基于使用/{slug}
模式的 slug 进行位置快捷方式。
我最后加载了我的包的路由(在所有其他路由之后)......</p>
# (File: app/config/routing.yml)
# Locations
# =========
# Note: this is intentionally last because locations must match root-relative
# wildcard slugs (eg: /atlanta /alberta /boston) for location and city pages.
foo_locations:
resource: "@FOOLocationsBundle/Resources/config/routing.yml"
prefix: /
…最后定义捷径…</p>
# (File: src/FOO/LocationsBundle/Resources/config/routing.yml)
# Location Alias/Shortcuts
# ========================
# NOTE: this must be the last route defined so that it does not get clobbered
# by other routes
foo_location_shortcut:
pattern: /{slug}
defaults: { _controller: FOOLocationsBundle:Default:shortcut }
我想通过最后加载这些路线,它会允许其他路线首先匹配。情况似乎并非如此。大多数(尽管不是全部)其他路由将调用该FOOLocationsBundle:Default:shortcut
操作。
这个问题似乎最接近我能找到的答案,但它似乎在需求中定义了明确的匹配,这对我不起作用,因为这些 slug 是在 CMS 中管理的。