问题描述
我正在使用zfcUser
,我想知道是否有可能因为我不想公开默认路由而禁用默认路由,例如zfcUser/login
,zfcUser/register
等.
I'm using zfcUser
and I was wondering if its possible to disable the default routes, such as zfcUser/login
, zfcUser/register
, etc because I do not want to expose them.
我看着zfcuser.global.php
,但是似乎没有这样的选择?
I looked at the zfcuser.global.php
but there seems to be no such option?
谢谢
推荐答案
您可以通过设置空控制器或不匹配的路由配置来简单地覆盖配置.
You can simply override the configuration by setting a null controller or an unmatchable routing configuration.
解决方案1:覆盖zfcuser
控制器可调用项:
Solution 1: override the zfcuser
controller invokable:
// YourApp\Module#getConfig() or config/autoload/zfcuser.override.global.php
return array(
'controllers' => array(
'invokables' => array(
'zfcuser' => null,
),
),
);
解决方案2:通过使用自己的路由配置(hacky,不鼓励)覆盖路由配置:
Solution 2: overriding routing configuration by using your own route config (hacky, discouraged):
// 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,
),
),
),
),
),
),
),
);
这篇关于禁用默认的zfcUser路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!