Silly\Application::useContainer PHP Method

useContainer() public method

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.
public useContainer ( Interop\Container\ContainerInterface $container, boolean $injectByTypeHint = false, boolean $injectByParameterName = false )
$container Interop\Container\ContainerInterface Container implementing container-interop
$injectByTypeHint boolean
$injectByParameterName boolean
    public function useContainer(ContainerInterface $container, $injectByTypeHint = false, $injectByParameterName = false)
    {
        $this->container = $container;
        $resolvers = [new AssociativeArrayResolver(), new HyphenatedInputResolver()];
        if ($injectByTypeHint) {
            $resolvers[] = new TypeHintContainerResolver($container);
        }
        if ($injectByParameterName) {
            $resolvers[] = new ParameterNameContainerResolver($container);
        }
        $this->invoker = new Invoker(new ResolverChain($resolvers), $container);
    }