开发者

Symfony sfGuardPlugin: disable default routes

I'm using the sfGuardPlugin in symfony 1.4 and I'm wondering how to get rid of its "default" routes. I mean by that the "guard/users", "guard/permissions" and "guard/groups" routes.

开发者_运维问答

Indeed I have designed my own backend without admin generator, and I've recreated these three pages with customs urls. So how can I disable the access to the default sfGuard pages ?


app.yml:

all:
  sf_guard_plugin:
    routes_register: false

as stated in the documentation.


You should update the file

/config/sfDoctrineGuardPluginConfiguration.class.php

to the lasted version.

Before the lasted update, despite the documentation, the routes did get registed anyway.

It seems you are using the previous version of this file.


To desactivate these 3 modules : you just have to remove the sfGuardGroup, sfGuardUser, sfGuardPermission from the settings.yml for backend application.

all:
  .settings:
    enabled_modules: [default, sfGuardAuth, sfGuardGroup, sfGuardUser, sfGuardPermission]

In order to keep only the authentification module

all:
  .settings:
    enabled_modules: [default, sfGuardAuth]

However I have no idea what default is.


If you (i) still want to use the modules provided by the plugin, (ii) using your own routes, (iii) preventing people from using the default sfGuard routes and (iv) still have the default /:module/:action route (which is rather useful), you can override the sfGuardRouting class, which is here

plugins/sfGuardPlugin/lib/routing/sfGuardRouting.class.php

You can simply copy this file to your

lib/

directory and then play with the methods. For instance I just commented all the code of all methods of the class (since I made my own routes in my apps/myApp/config/routing.yml file) for the modules of the sfGuardPlugin), like this

class sfGuardRouting
{
  static public function listenToRoutingLoadConfigurationEvent(sfEvent $event)
  {
   //    $r = $event->getSubject();
   // preprend our routes
   //    $r->prependRoute('sf_guard_signin', new sfRoute('/guard/login', array('module' => 'sfGuardAuth', 'action' => 'signin'))); 
   //    $r->prependRoute('sf_guard_signout', new sfRoute('/guard/logout', array('module' => 'sfGuardAuth', 'action' => 'signout'))); 
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜