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

Support dependency injection for factory functions in Container config #97

Merged
merged 1 commit into from
Dec 20, 2021

Conversation

clue
Copy link
Owner

@clue clue commented Dec 17, 2021

This changeset adds support for dependency injection for factory functions in the Container configuration. This allows us to fine-tune the autowiring behavior and explicitly configure individual parameters while relying on autowiring defaults for other parameters. This does not otherwise break existing APIs, so this is a pure feature addition.

<?php

require __DIR__ . '/../vendor/autoload.php';

$container = new FrameworkX\Container([
    Acme\Todo\UserController::class => function (React\Http\Browser $browser) {
        // example UserController class requires two arguments:
        // - first argument will be autowired based on class reference
        // - second argument expects some manual value
        return new Acme\Todo\UserController($browser, 42);
    }
]);

// …

Builds on top of #96

@clue clue added the new feature New feature or request label Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants