tccltd/tcc-skippable-segment

该软件包最新版本(1.0.1)没有可用的许可证信息。

可跳过的路由配置

1.0.1 2015-04-10 12:18 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:18:56 UTC


README

本模块基于以下工作:@towr (https://gist.github.com/towr/3320fb4ee13dfd079890).

它允许您指定可以跳过的路由段(例如:[/:lang]/my-page/anotherpage - lang部分可以省略)。

使用方法

可跳过的路由段路由。修改后的路由段,其中您可以跳过可选段。

'router' => [
    'routes' => [
        'home' => [
            'type' => 'SkippableSegment',
            'options' => [
                'route' => '[/:lang]',
                'constraints' => [
                    'lang' => '(?i:en|us)',
                ],
                'defaults' => [
                    'lang' => '',
                    'controller' => 'MyController',
                    'action' => 'index'
                ],
                'skippable' => [
                    'lang' => true,
                ],
            ],
            'may_terminate' => true,
            'child_routes' => [
                'my-page' => [
                    'type' => 'Segment',
                    ...
                    ...
                ],
            ],
        ],
    ],
);