[Core] Add Service Locator class

Review Request #19 — Created Dec. 4, 2012 and submitted — Latest diff uploaded

pprkut
Lunr
pprkut/remove_references
lunr
This is the long awaited implementation of the ServiceLocator pattern. It looks quite simple, but it took quite some trial & error to get it like this. Not a simple topic :/
So, how does it work?

Singelton use-case:

$locator->configuration = $locator->as_singleton(function ($config = FALSE)
{
    return new Lunr\Libraries\Core\Configuration($config);
});

$config = $locator->configuration($config_array);

Normal use-case:

$locator->datetime = function ()
{
    return new Lunr\Libraries\Core\DateTime();
};

$datetime = $locator->datetime();

oh, and it still works with PHP 5.3 :)

This depends on http://reviews.lunr.nl/r/23/
Unit tests
Test implementation for AMC
Loading...