-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFR] Phalcon\DI: Info on whether DI service has been resolved #1242
Comments
The quick fix is to override |
@sjinks Thanks for the tip. Is there a plan to implement it on DI level? |
@phalcon What do you think? |
@temuri416 why do you need to do this? |
Here's what I'm doing in my project.
The problem is that I do not know whether certain log devices have been used at all (LOGD_AUTH, for example, is only used once per user session). I do not want to run into overhead of resolving log devices in DI that may have not been used. (On a side note - there's another related problem - I need to know whether a log device has initiated a transaction - see #1238). I have implemented a temporary workaround. But in my opinion, this belongs to system level. |
Can you please update me - is this categorized as "won't fix" ? Thanks! |
#1238 is merged on 1.3.0 I'm keeping this open, if anyone wants to implement this |
See #1319 $di = new \Phalcon\Di();
$di->set('resolved', function() { return new Whatever(); });
$di->set('notresolved', function() { return new Whatever(); });
$this->assertFalse($di->getService('resolved')->isResolved());
$this->assertFalse($di->getService('notresolved')->isResolved());
$di->get('resolved');
$this->assertTrue($di->getService('resolved')->isResolved());
$this->assertFalse($di->getService('notresolved')->isResolved()); |
This is implemented in 1.3.0 |
In Phalcon\DI: add an attribute (and getter method) to indicate whether a service has been resolved.
I have my DI container with custom service in it:
Shared service "whatever" may or may not be resolved (instantiated/set) by my application.
At the end of request cycle I need to know whether it was resolved or not.
Obviously, I don't want to do:
because that will resolve it for sure.
I need a way of knowing whether shared service "whatever" has been resolved or not.
Thanks,
Temuri
The text was updated successfully, but these errors were encountered: