symfony/symfony — pull request #9839 by realityking (2013-12-22 11:19:54+00:00)
Title: [WIP][DependencyInjection] Add a new Syntax to define factories as callables.

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -

This pull requests adds a new syntax to define factories based on the syntax for configurators. This is more flexible than the old syntax (factoryMethod and either of factoryClass or factoryService), as it also allows for functions as factories.

Since the service is now a Reference to a Definition it also allows us to inline factories for a small performance improvement and better encapsulation.

Lastly this prevents a bug where a private factory is simple removed because it's not referenced in the graph.

I did not change any of the existing definitions (there's one use of a factory in FrameworkBundle) or automatically use the new internal representation when parsing YAML or XML definitions because this could introduce subtle B/C issues.

There are still a few things left to do (see list below), I wanted a general thumbs up on the approach and the deprecation before I continue.

Todo:
- [ ] Write documentation
- [ ] Update UPGRADE-3.0.md
- [ ] Add a check to CheckDefinitionValidityPass to validate only one factory is defined.