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

Resolve/instantiate factories using the container #308

Merged
merged 3 commits into from
Sep 6, 2015
Merged

Resolve/instantiate factories using the container #308

merged 3 commits into from
Sep 6, 2015

Conversation

mnapoli
Copy link
Member

@mnapoli mnapoli commented Sep 2, 2015

Fix #179, start of #197

return [
    'Foo' => DI\factory(['FooFactory', 'create']),
];

With this configuration, FooFactory will be created by the container.

If FooFactory::create() is static, no instance will be created (and the method will be called statically).

Performance tests and profiling showed a performance regression of up to +40% (worst case) to resolve factories (after working on optimizations). I think this is acceptable given it's only a small part of the whole container (the total performance regression should be negligible, especially since 5.1 already brings good improvements to compensate).

TODO:

  • documentation
  • changelog

@mnapoli mnapoli added this to the 5.1 milestone Sep 2, 2015
@mnapoli mnapoli changed the title Resolve factories from the container using the invoker Resolve factories from the container Sep 6, 2015
@mnapoli mnapoli changed the title Resolve factories from the container Resolve/instantiate factories using the container Sep 6, 2015
mnapoli added a commit that referenced this pull request Sep 6, 2015
Resolve/instantiate factories using the container
@mnapoli mnapoli merged commit 308c2cf into master Sep 6, 2015
@mnapoli mnapoli deleted the 179 branch September 6, 2015 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for DI\link() in factory definitions (arrays)
1 participant