-
Notifications
You must be signed in to change notification settings - Fork 64
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
GetSubscribedEvents on partially initialized instance. #63
Comments
It's meant to be static, but I'm not sure we can do that because of I don't see how the instance can be created properly in compile time. The listener might depend on classes that require shitload of dependencies. I would have to fake-compile the entire container to be able to properly create the listener instances. Any ideas? |
I suppose we can create the listener "properly", when the constructor has no dependencies or when it depends only on parameters, not services. Any thoughts? |
Well, let me clear the need, then it may be more obvious. I have a neo4j services, which store some metadata (and updated them through events). I have it also on my local machine, but not every developer should be forced to have it, since it's just small part of the app. So I would like to add listener somehow conditionaly. This was the first idea (the easiest): to let me inject my ParameterProvider, when I have option for it. What is the proper solution? |
You might have a listener that is invoked on connection to database or application init, that adds another listener if needed. You don't have to specify all events in the Might something like this help? class SomeListener implements Subsriber
{
public function __construct(EventManager $evm)
{
// ...
}
public function getSubscribedEvents()
{
return ['Neo4js::onConnect'];
}
public function onConnect(...)
{
// ...
$this->evm->addEventListener('Neo4js::onMetadataUpdate', [$this, 'onMetadataUpdate']);
}
public function onMetadataUpdate(..)
{
// ...
} Doctrine uses similar mechanism to add listener for But I'm not sure I've understood you properly. Možná to bude snadnější česky? |
You understood it correcty. The problem is, the connection is needed only when the event occurs. |
Well, I solved this by own extension. So, I don't need any features for doing this, but I would force the getSbscribedEvents to be static. |
I don't consider this a problem. If you provide better solution that will not break BC, I shall consider it. |
What? Why should I provide solution for something ,which isn't a problem :P |
getting the subscribed events is quite hacky, for example injections are not injected... so, it is impossible to do any logic in there. I see no added value in this, make it static, or create the instance properly, what do you think?
The text was updated successfully, but these errors were encountered: