Hi,

Tomasz Ignatiuk schrieb:
> Unfortunatelly still I don't know how to do this, I mean trigger this
> for every action that saves or updates data.
> 
> sfPropelModifiedByUserBehavior::setUserId($userId);
> 
> where $userId is taken from a session.
> Could someone help me, please?!

You probably already have some myUser class in your app/<appname>/lib
directory managing your session data, don't you?

Now add the following method to this class. It will be called on every
request when setting up the framework. The parent class' initialize
method will load the session data, so you have your user information
available as attributes.

  public function initialize($context, $parameters = null)
  {
    parent::initialize($context, $parameters);

    // change this code get the actual user ID!                <---
    $userId = $this->getAttribute('id', null, 'user');

    // pass down the currently logged in user's ID to persistence layer
    sfPropelModifiedByUserBehavior::setUserId($userId);
  }


For symfony 1.1+ you'll have to change the signature taking into account
the new dependency injection techniques:
public function initialize(sfEventDispatcher $dispatcher, sfStorage
$storage, $options = array())
Everything else should work the same.

If you want to have the plugin's behavior available in the login action
itself as well, then you'll have to take special care for that, like
calling sfPropelModifiedByUserBehavior::setUserId($userId) in the
signIn() method you probably have if you followed some symfony tutorials.

Martin

--~--~---------~--~----~------------~-------~--~----~
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