Skip to content

Resolve/instantiate factories using the container#308

Merged
mnapoli merged 3 commits intomasterfrom
179
Sep 6, 2015
Merged

Resolve/instantiate factories using the container#308
mnapoli merged 3 commits intomasterfrom
179

Conversation

@mnapoli
Copy link
Copy Markdown
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