Re: Singletons
| From: | Jochem Maas | Date: | Tue, 21 Oct 2008 01:17:21 +0000 |
| Subject: | Re: Singletons | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-282164@lists.php.net to get a copy of this message | ||
Christoph Boget schreef:
>> Create your singleton class without extending the class you need to extend.
>> Create an instance of that class in your object. Implement the __call magic
>> method to proxy function calls through to that instance throwing an
>> exception (or error) if the method requested doesn't exist. Not particularly
>> pretty, but definitely simple.
>
> No, not pretty at all though it would address my issues. Thanks for the idea!
or use a registry pattern to store your singleton objects and use the registry
to retrieve the instances. this requires some discipline in that the registry should
always be the interface through which your objects are retrieved ... discipline
is always and issue when writing code :-)
>
> thnx,
> Christoph
>