[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jfw] Re: Container and use of an alias

As I wrote before, removing that line from getRaw and exists only gives true when using the long key not with the alias.

Am Dienstag, 16. Dezember 2014 21:01:46 UTC+1 schrieb Don Gilbert:
Correct. And I've issued a fix for that. Waiting for tests to pass so we can merge and tag.

This is really a bug fix release, so it should be labeled as 1.3, as it does not break backward compatibility, but rather resolves a longstanding (but unknown) bug.

Thanks for you help in discovering this Sven!

On Tuesday, December 16, 2014 1:58:51 PM UTC-6, Sven Versteegen wrote:

The issue I experience is that I set a shared object to the container, when you retrieve it with the long key it will set an instance to the instances array with that long key, but if you try then to get that "shared" object with the alias key you will get a newly created one and set to the instances array with the alias key.

Am Dienstag, 16. Dezember 2014 20:46:34 UTC+1 schrieb Don Gilbert:
I've added tests to prove this and created a PR: https://github.com/joomla-framework/di/pull/10

Sven, I think the issue you are experiencing is that the callable you are passing ( [$this, 'getResponse'] ) returns a different object. If you register your key with a callback, that exact callback is used when fetching the item from the container, not the value returned by the callback. So you are getting, each time you get it from the container, the value returned by your $this->getResponse() method (as in, that method is called every time you request $c->get('jresponse');

If you want to use the value, simply register it like this:

$c->set('MyApp\\Interfaces\\App\\AppResponseInterface', $this->getResponse(), true, true)
  ->alias('jresponse', 'MyApp\\Interfaces\\App\AppResponseInterface');

Framework source code: https://github.com/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.