Skip to content
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

[PROPOSAL] Remove memory caching of entity listeners #277

Open
zquintana opened this issue Sep 18, 2017 · 1 comment
Open

[PROPOSAL] Remove memory caching of entity listeners #277

zquintana opened this issue Sep 18, 2017 · 1 comment

Comments

@zquintana
Copy link

In the current version of this package the EntityListenerResolver memory caches instances of resolved listeners. This overrides the current behavior of the Laravel container. For example if a develop defines a listener as a factory (bind in Laravel) then it's turned into a singleton via this resolver. This breaks the container definition and forces developers to treat listeners as singletons. Where performance is an issue a developer can still define the listener as a singleton in container via singleton method in the container. Which also means that these checks at https://github.com/laravel-doctrine/orm/blob/1.4/src/Resolvers/EntityListenerResolver.php#L51 are a duplication of what already happens in the make method of the container.

For these reasons my proposal is that the resolve method of the listener be simplified to not cache instances created by the containers make method. It should still check to see if there is an instance in instances property for listeners that have been registered via register method.

@patrickbrouwers
Copy link
Contributor

Feel free to PR it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants