[Solar-talk] Re: Solar::register()
Paul M Jones
pmjones at solarphp.com
Sun May 7 17:56:18 PDT 2006
Hi Antti,
> I was wondering
> wouldn't it make sense for register() to just return; if the class
> with the same name already exists in the registry and not throw an
> Exception. You'd get rid of all the inRegistry() checks. Does this
> make sense at all?
Recall first that Solar::register() supports both direct object
registry *and* lazy-loading of objects. For example:
// register an object instance
$example = Solar::factory('Solar_Text_Example');
$result = Solar::register('example0', $example);
// register a Solar_Test_Example object for lazy-loading
Solar::register('example1', 'Solar_Test_Example');
// then later, we try (for some reason) to register another one,
// but with a different name (no exception thrown).
$result = Solar::register('example2', 'Solar_Test_Example');
// but if you try to register an object with the same name,
// it currently throws an exception.
$result = Solar::register('example1', 'Solar_Test_Example');
If I understand correctly, you're saying that $result, in all cases,
should be an object instance of the Solar_Test_Example class. If so,
then it defeats the purpose of lazy-loading; it would always have to
instantiate an object.
Let me know if I have I missed your point here.
--
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