public function useContainer(
        ContainerInterface $container,
        $injectByTypeHint = false,
        $injectByParameterName = false
    ) {
        $this->container = $container;

        $resolver = $this->createParameterResolver();
        if ($injectByTypeHint) {
            $resolver->appendResolver(new TypeHintContainerResolver($container));
        }
        if ($injectByParameterName) {
            $resolver->appendResolver(new ParameterNameContainerResolver($container));
        }

        $this->invoker = new Invoker($resolver, $container);
    }
public function useContainer(
        ContainerInterface $container,
        $injectByTypeHint = false,
        $injectByParameterName = false
    ) {
        $this->container = $container;

        $resolver = $this->createParameterResolver();
        if ($injectByTypeHint) {
            $resolver->appendResolver(new TypeHintContainerResolver($container));
        }
        if ($injectByParameterName) {
            $resolver->appendResolver(new ParameterNameContainerResolver($container));
        }

        $this->invoker = new Invoker($resolver, $container);
    }
public function useContainer ( ContainerInterface $ container , $ injectByTypeHint = false , $ injectByParameterName = false ) { $ this -> container = $ container ; $ resolver = $ this -> createParameterResolver ( ) ; if ( $ injectByTypeHint ) { $ resolver -> appendResolver ( new TypeHintContainerResolver ( $ container ) ) ; } if ( $ injectByParameterName ) { $ resolver -> appendResolver ( new ParameterNameContainerResolver ( $ container ) ) ; } $ this -> invoker = new Invoker ( $ resolver , $ container ) ; }
Set up the application to use a container to resolve callables.

Only commands that are *not* PHP callables will be fetched from the container.
Commands that are PHP callables are not affected (which is what we want).

*Optionally*, you can also enable dependency injection in the callable parameters:

$application->command('greet', function (Psr\Log\LoggerInterface $logger) {
$logger->info('I am greeting');
});

Set `$injectByTypeHint` to `true` to make Silly fetch container entries by their
type-hint, i.e. call `$container->get('Psr\Log\LoggerInterface')`.

Set `$injectByParameterName` to `true` to make Silly fetch container entries by
the parameter name, i.e. call `$container->get('logger')`.

If you set both to `true`, it will first look using the type-hint, then using
the parameter name.

In case of conflict with a command parameters, the command parameter is injected
in priority over dependency injection.

@param ContainerInterface $container Container implementing PSR-11
@param bool               $injectByTypeHint
@param bool               $injectByParameterName
Set up the application to use a container to resolve callables .