[Solar-talk] Solar_Event_Dispatcher (was: tests in the browser)
Paul M Jones
pmjones at solarphp.com
Mon Oct 16 07:30:30 PDT 2006
On Sep 20, 2006, at 3:43 PM, Rodrigo Moraes wrote:
> Is not that simple, don't you think? I wish Solar had an auto-registry
> method, more or less like the dependency method, but also registering
> objects after creation:
>
> -> try the registry
> -> not registered? factory and register; return the created
> object
> -> registered? return the object
>
> Bad idea? We have to register every instance before using. Not a
> problem, anyway, I'm just wondering if it could be more automatic or
> error-proof.
If I understand your request properly, Solar::register() already does
this. You can specify a "lazy-load" registration like so:
$name = 'example';
$class = 'Solar_Test_Example';
$config = array(...); // or set to null for defaults
Solar::register($name, $class, $config);
Then when you call Solar::registry('example') it will construct and
configure the class for you at that moment.
Does that help at all?
--
Paul M. Jones <http://paul-m-jones.com>
Solar: Simple Object Library and Application Repository
for PHP5. <http://solarphp.com>
Savant: The simple, elegant, and powerful solution for
templates in PHP. <http://phpsavant.com>
More information about the solar-talk
mailing list