Symfony2 - 路线

时间:2016-04-23 13:57:19

标签: symfony doctrine-orm routing slug

我正在使用SF2 Framework,我想实现类似这样的路由:

mywebsite.com/en/customer/sensiolab/employee/johndoe/statistics

其中“sensiolab”和“johndoe”都是slu ..

现在,我创建了像这样的全局Controller路线:

/**
 * Statistics controller.
 *
 * @Route("/customer/{customer_slug}/employee/{employee_slug}/statistics")
 * @ParamConverter("customer", class="AppBundle:Customer", options={"id" = "customer_slug", "repository_method" = "findOneBySlug"})
 * @ParamConverter("employee", class="AppBundle:Employee", options={"id" = "employee_slug", "repository_method" = "findOneBySlug"})
 */
class StatisticsController extends Controller {

它工作得很好,但这意味着我需要在几乎每个链接中指定customer_slug和employee_slug,并在每个控制器中传递此信息......

是否有解决方案可以轻松实现此路径结构。是否有可能像我为_locale做的那样(效果很好)?

谢谢,

0 个答案:

没有答案