2
我使用zfcUser
,我想知道是否可以禁用默認路由,如zfcUser/login
,zfcUser/register
等,因爲我不想公開它們。禁用默認zfcUser路由?
我看着zfcuser.global.php
但似乎沒有這樣的選擇?
感謝
我使用zfcUser
,我想知道是否可以禁用默認路由,如zfcUser/login
,zfcUser/register
等,因爲我不想公開它們。禁用默認zfcUser路由?
我看着zfcuser.global.php
但似乎沒有這樣的選擇?
感謝
你可以簡單地通過設置一個空控制器或無可比擬的路由配置覆蓋配置。
解決方案1:覆蓋zfcuser
控制器可調用:
// YourApp\Module#getConfig() or config/autoload/zfcuser.override.global.php
return array(
'controllers' => array(
'invokables' => array(
'zfcuser' => null,
),
),
);
解決方案2:重寫使用自己的路由配置(哈克,氣餒)路由配置:
// 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,
),
),
),
),
),
),
),
);
這似乎你的答案被縮短了;你可以再次發佈NullRoute建議嗎? – KaiserJohaan 2013-03-19 09:19:21
@KaiserJohaan'NullRoute'建議實際上太方便了。我決定拆除它,因爲它很長,與上面提到的解決方案相比,它沒有任何好處。 – Ocramius 2013-03-19 09:22:35
僅供參考,第一種解決方案應該沒問題,因爲它基本上完全取消了'zfcuser'控制器,這也是安全的。 – Ocramius 2013-03-19 09:23:45