Can I force Yii DI to use defined static factory method?

This is related to a dependency of a dependency in my code. Not sure why my config fails here, but I do

    $config    = ContainerConfig::create()
        ->withDefinitions(
            [
                'Settings' => [Settings::class, 'make'],
            ]
        );
    $container = new Container($config);
    $injector  = new Injector($container);
    $c         = $injector->make($classname);

but my error log shows that the constructore, and not the make method, is called. Any clues? Is the autowiring not recursive?

Wrong usage of config by me, since the settings class is namespaced, it should be

    $config    = ContainerConfig::create()
        ->withDefinitions(
            [
                Settings::class => [Settings::class, 'make'],
            ]
        );
1 Like