[symfony-users] Re: how to get current login user id in my commonclass??

2009-09-16 Thread Sebastien Armand [Pink]
If I remember,
calling sfContext::getInstance() is not really recommended because the
context is not always defined (if you are performing tests or run the CLI
for example, but I'm not 100% sure) and the preferred way is to pass the
information to the class you want to use from the action:

$myClassObject-myMethod($this-getUser());

or

$myClassObject-setUser($this-getUser());
$myClassObject-myMethod();

2009/9/16 Avani avani.v.puj...@gmail.com


 Hi Olly,

 Thanks a lot.. It's working  :)



 On Sep 15, 4:29 pm, Oliver Jackson ojack...@valleyt.co.uk wrote:
  Avani wrote:
   Hello Everyone,
 
   I have one common class for my own functions and I have stored it in
   lib/common.class.php
 
   My problem is, how to get current login userid from that class?
 
   I tried
   1. $this-getUser()-getProfile()-getUserId();
   2. $sf_user-getProfile()-getUserId();
 
  Try:
 
  sfContext::getInstance()-getUser()-getProfile()-getUserId();
 
  Olly
 
  --
  Oliver Jackson - Senior Developer
  Valley Technology - +44 (0)131 553 0412
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: how to get current login user id in my commonclass??

2009-09-15 Thread Oliver Jackson

Avani wrote:
 Hello Everyone,

 I have one common class for my own functions and I have stored it in
 lib/common.class.php

 My problem is, how to get current login userid from that class?

 I tried
 1. $this-getUser()-getProfile()-getUserId();
 2. $sf_user-getProfile()-getUserId();

   
Try:

sfContext::getInstance()-getUser()-getProfile()-getUserId();

Olly

-- 
Oliver Jackson - Senior Developer
Valley Technology - +44 (0)131 553 0412


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: how to get current login user id in my commonclass??

2009-09-15 Thread Avani

Hi Olly,

Thanks a lot.. It's working  :)



On Sep 15, 4:29 pm, Oliver Jackson ojack...@valleyt.co.uk wrote:
 Avani wrote:
  Hello Everyone,

  I have one common class for my own functions and I have stored it in
  lib/common.class.php

  My problem is, how to get current login userid from that class?

  I tried
  1. $this-getUser()-getProfile()-getUserId();
  2. $sf_user-getProfile()-getUserId();

 Try:

 sfContext::getInstance()-getUser()-getProfile()-getUserId();

 Olly

 --
 Oliver Jackson - Senior Developer
 Valley Technology - +44 (0)131 553 0412
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---