arg example

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo;

return function DContainerConfigurator $c) {
    $c->parameters()
        ('foo', 'Foo')
        ('bar', 'Bar')
    ;
    $c->services()->defaults()->public()
        (Foo::class)
            ->arg('$bar', service('bar'))
            ->public()
        ('bar', Foo::class)
            ->call('setFoo')
    ;
};
protected function configureContainer(ContainerConfigurator $c): void
    {
        $c->parameters()
            ->set('halloween', 'Have a great day!');

        $c->services()
            ->set('logger', NullLogger::class)
            ->set('stdClass', 'stdClass')
                ->autowire()
                ->factory([$this, 'createHalloween'])
                ->arg('$halloween', '%halloween%');

        $c->extension('framework', [
            'annotations' => false,
            'http_method_override' => false,
            'handle_all_throwables' => true,
            'php_errors' => ['log' => true],
            'router' => ['utf8' => true],
        ]);
    }
}
Home | Imprint | This part of the site doesn't use cookies.