Hi Daniel,

> I thought you'd just wrap getObject/getObjects with your own
> implementation and not create a new method for it so it's a bit hard
> to convert, for instance, standard admin generator modules to use
> these new route classes

Overriding getObject() would have been the best solution, but
unfortunately I need the user in the route. Since I may not modify the
signature of getObject(), I created a new method and threw an
exception in getObject() instead. If the route would have access to
the sfUser otherwise, one could of course do as you suggested.

For the admin generator we created a proxy route class:

public function SecureObjectRouteProxy
{
  protected
    $user = null,
    $route = null;

  public function __construct(SecureObjectRoute $route, sfUser $user)
  {
    $this->user = $user;
    $this->route = $route;
  }

  public function getObject()
  {
    return $this->route->getObjectAuthorizedFor($this->user);
  }
}

You only need to override getRoute() in the admin generator actions to
make it all work. Again, if symfony would support secured routing, you
could get rid of that customization completely.


Bernhard
--
Software Architect & Engineer
Blog: http://webmozarts.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to