禁用默认的zfcUser路由?

时间:2013-03-19 08:40:24

标签: zend-framework2 zfcuser

我正在使用zfcUser,我想知道是否可以禁用默认路由,例如zfcUser/loginzfcUser/register等,因为我不想公开它们。< / p>

我看了zfcuser.global.php,但似乎没有这样的选择?

由于

1 个答案:

答案 0 :(得分:3)

您可以通过设置空控制器或不匹配的路由配置来覆盖配置。

解决方案1:覆盖zfcuser控制器invokable:

// YourApp\Module#getConfig() or config/autoload/zfcuser.override.global.php

return array(
    'controllers' => array(
        'invokables' => array(
            'zfcuser' => null,
        ),
    ),
);

解决方案2:使用您自己的路由配置覆盖路由配置(hacky,disouraged):

// YourApp\Module#getConfig() or config/autoload/zfcuser.override.global.php

return array(
    'router' => array(
        'routes' => array(
            'zfcuser' => array(
                // changing to hostname route - using an unreachable hostname
                'type' => 'Hostname',
                // minimum possible priority - all other routes come first.
                'priority' => ~PHP_INT_MAX,
                'options' => array(
                    // foo.bar does not exist - never matched
                    'route' => 'foo.bar',
                    'defaults' => array(
                        'controller' => null,
                        'action' => 'index',
                    ),
                ),

                // optional - just if you want to override single child routes:
                'child_routes' => array(
                    'login' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'authenticate' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'logout' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'register' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'changepassword' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'changeemail' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
);