Re: Singleton behaviour of LiveUser_Admin??
Lukas Smith <[email protected]>
| Newsgroups | gmane.comp.php.pear.liveuser |
|---|---|
| Organization | BackendMedia GbR |
| Message-ID | <[email protected]> |
Tim Daeleman wrote:
> Hi,
>
>
> thanks to your help I got the singleton behaviour for LiveUser working.
>
> --
> i.e.
> $conf = ...full config array...;
> $oLU = LiveUser::singleton($conf);
>
> and inside a class definition then call:
>
> $this->oLU = LiveUser::singleton($emptyConf);
>
> has me referencing the same LU object.
we fixed this in CVS and you can now do:
$LU = LiveUser::singleton($conf);
LU2 = LiveUser::singleton();
> --
>
> When I try to do the same with the LiveUser_Admin class it doesn't work.
> The reason for this is that I have to submit a autoInit option set to
> true for LiveUser_Admin to ork (don't ask me why).
>
> So the first part works:
>
> --
> $conf = ...full config array...;
> $oLUA = LiveUser_Admin::singleton($conf);
>
> But when I am in a class definition and call
>
> $this->oLUA = LiveUser_Admin::singleton($emptyConf);
> It doesn't work, the already instantiated LU_Admin object isn't "found".
> And because I don't have access to the config array within the class
> definition I can't resubmit it. Just setting $emptyConf["autoInit"] =
> true breaks everything even more.
>
> Any idea how I can get this to work?? Again I don't want to throw around
> config arrays and LU objects.
Uhm .. that should work.
this is the implementation .. i dont know how it could give you the
original instance again ..
function &singleton($conf)
{
static $instance;
if (!isset($instance)) {
$obj = &LiveUser_Admin::factory($conf);
$instance =& $obj;
}
return $instance;
}
does it try to create a new instance with the empty config array?
regards,
Lukas Smith
[email protected]
_______________________________
BackendMedia
www.backendmedia.com
[email protected]
Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin
Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07