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

Allow factory methods to be called with a factory constructor #14

Open
cameroncondry opened this issue Aug 1, 2014 · 0 comments
Open

Comments

@cameroncondry
Copy link

Now that the ability for factory methods to reference the DI container exists (#13), can we allow factory methods to be called with the existing class method using a factory callable constructor? I would image the functionality of the new constructor method would be similar to how the current "addMethodCall" works.

Example:

class MyClassFactory
{
    public static function createMyClass(Container $di)
    {
        return $di->get(MyClass::class);
    }
}

$di
    ->register(MyClass::class, 'class')
    ->toClass(MyClassFactory::class)
    ->setConstructor('createMyClass', [$optionalArg1, $optionalArg2])
;
@cameroncondry cameroncondry changed the title Allow factory methods to be called with a factory constructor #13 Allow factory methods to be called with a factory constructor Aug 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants