2

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

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

谢谢

4

1 回答 1

3

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

解决方案1:覆盖zfcuser控制器可调用:

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

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

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

// 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,
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
);
于 2013-03-19T08:59:01.943 回答