Re: Class not functioning
| From: | Shawn McKenzie | Date: | Tue, 15 Dec 2009 22:30:41 +0000 |
| Subject: | Re: Class not functioning | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-300538@lists.php.net to get a copy of this message | ||
Allen McCabe wrote:
> Hey all (and Nirmalya, thanks for the help!),
>
>
> I have a question that I just can't seem to find via Google.
>
> I want to be able to add messages to a qeue whenever my classes complete (or
> fail to complete) specific functions. I think have a call within my html to
> my Notifier class to print all qeued messages (via a function 'printQ').
>
> How do I access a globally instantiated class from within another class?
>
> Example:
>
> <?php
>
> // INSTANTIATE
> $Meetgreet = new Meetgreet;
> $Notify = new Notifier;
>
> ...
> ...
>
> $Meetgreet->deleteSingle($id, 1); // This completes a function within
> Meetgreet class. That function needs to be able to use the Notifier function
> addtoQ(), how would this be accomplished?
>
> ?>
> ...
> ...
>
Several ways to do it. One would be to make the Meetgreet a singleton
if it really is, and then use its static getInstance. I would probably
use a registry pattern though.
--
Thanks!
-Shawn
http://www.spidean.com