beberlei / yadif

Yet Another (PHP) Dependency Injection Framework
Other
37 stars 1 forks source link

Allow Factory Method Instatiation through other component #13

Open beberlei opened 14 years ago

beberlei commented 14 years ago

It should be possible to bind the creation of a Service to a factory method that is located on another component, for example:

$builder->bind('Doctrine\ORM\EntityManager')->to($entityManager);
$builder->bind('MyRepository')->toProvider(array('Doctrine\ORM\EntityManager'))->args('MyEntityName');

This works with the following simple patch:

Index: Yadif/Container.php

--- Yadif/Container.php (revision 28379) +++ Yadif/Container.php (working copy) @@ -432,7 +432,11 @@ $setterMethods = $component[self::CONFIG_METHODS];

     if(isset($component[self::CONFIG_FACTORY])) {