nullOnInvalid example

use Symfony\Component\Scheduler\Command\DebugCommand as SchedulerDebugCommand;
use Symfony\Component\Serializer\Command\DebugCommand as SerializerDebugCommand;
use Symfony\Component\Translation\Command\TranslationPullCommand;
use Symfony\Component\Translation\Command\TranslationPushCommand;
use Symfony\Component\Translation\Command\XliffLintCommand;
use Symfony\Component\Validator\Command\DebugCommand as ValidatorDebugCommand;

return static function DContainerConfigurator $container) {
    $container->services()
        ->set('console.error_listener', ErrorListener::class)
            ->args([
                service('logger')->nullOnInvalid(),
            ])
            ->tag('kernel.event_subscriber')
            ->tag('monolog.logger', ['channel' => 'console'])

        ->set('console.suggest_missing_package_subscriber', SuggestMissingPackageSubscriber::class)
            ->tag('kernel.event_subscriber')

        ->set('console.command.about', AboutCommand::class)
            ->tag('console.command')

        ->set('console.command.assets_install', AssetsInstallCommand::class)
            
return static function DContainerConfigurator $container) {
    $container->services()
        ->set('error_handler.error_renderer.html', HtmlErrorRenderer::class)
            ->args([
                inline_service()
                    ->factory([HtmlErrorRenderer::class, 'isDebug'])
                    ->args([
                        service('request_stack'),
                        param('kernel.debug'),
                    ]),
                param('kernel.charset'),
                service('debug.file_link_formatter')->nullOnInvalid(),
                param('kernel.project_dir'),
                inline_service()
                    ->factory([HtmlErrorRenderer::class, 'getAndCleanOutputBuffer'])
                    ->args([service('request_stack')]),
                service('logger')->nullOnInvalid(),
            ])

        ->alias('error_renderer.html', 'error_handler.error_renderer.html')
        ->alias('error_renderer', 'error_renderer.html')
    ;
};
->set('fragment.uri_generator', FragmentUriGenerator::class)
            ->args([param('fragment.path')service('uri_signer')service('request_stack')])
        ->alias(FragmentUriGeneratorInterface::class, 'fragment.uri_generator')

        ->set('fragment.renderer.inline', InlineFragmentRenderer::class)
            ->args([service('http_kernel')service('event_dispatcher')])
            ->call('setFragmentPath', [param('fragment.path')])
            ->tag('kernel.fragment_renderer', ['alias' => 'inline'])

        ->set('fragment.renderer.hinclude', HIncludeFragmentRenderer::class)
            ->args([
                service('twig')->nullOnInvalid(),
                service('uri_signer'),
                param('fragment.renderer.hinclude.global_template'),
            ])
            ->call('setFragmentPath', [param('fragment.path')])

        ->set('fragment.renderer.esi', EsiFragmentRenderer::class)
            ->args([
                service('esi')->nullOnInvalid(),
                service('fragment.renderer.inline'),
                service('uri_signer'),
            ])
            
->set('serializer.normalizer.mime_message', MimeMessageNormalizer::class)
            ->args([service('serializer.normalizer.property')])
            ->tag('serializer.normalizer', ['priority' => -915])

        ->set('serializer.normalizer.datetimezone', DateTimeZoneNormalizer::class)
            ->tag('serializer.normalizer', ['priority' => -915])

        ->set('serializer.normalizer.dateinterval', DateIntervalNormalizer::class)
            ->tag('serializer.normalizer', ['priority' => -915])

        ->set('serializer.normalizer.data_uri', DataUriNormalizer::class)
            ->args([service('mime_types')->nullOnInvalid()])
            ->tag('serializer.normalizer', ['priority' => -920])

        ->set('serializer.normalizer.datetime', DateTimeNormalizer::class)
            ->tag('serializer.normalizer', ['priority' => -910])

        ->set('serializer.normalizer.json_serializable', JsonSerializableNormalizer::class)
            ->args([null, null])
            ->tag('serializer.normalizer', ['priority' => -950])

        ->set('serializer.normalizer.problem', ProblemNormalizer::class)
            ->args([param('kernel.debug'), '$translator' => service('translator')->nullOnInvalid()])
            
abstract_arg('http codes'),
                abstract_arg('delay ms'),
                abstract_arg('multiplier'),
                abstract_arg('max delay ms'),
                abstract_arg('jitter'),
            ])

        ->set('http_client.uri_template', UriTemplateHttpClient::class)
            ->decorate('http_client', null, 7) // Between TraceableHttpClient (5) and RetryableHttpClient (10)             ->args([
                service('.inner'),
                service('http_client.uri_template_expander')->nullOnInvalid(),
                abstract_arg('default vars'),
            ])

        ->set('http_client.uri_template_expander.guzzle', \Closure::class)
            ->factory([\Closure::class, 'fromCallable'])
            ->args([
                [\GuzzleHttp\UriTemplate\UriTemplate::class, 'expand'],
            ])

        ->set('http_client.uri_template_expander.rize', \Closure::class)
            ->factory([\Closure::class, 'fromCallable'])
            
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage;
use Symfony\Component\HttpKernel\Profiler\Profiler;

return static function DContainerConfigurator $container) {
    $container->services()
        ->set('profiler', Profiler::class)
            ->public()
            ->args([service('profiler.storage')service('logger')->nullOnInvalid()])
            ->tag('monolog.logger', ['channel' => 'profiler'])
            ->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.4'])

        ->set('profiler.storage', FileProfilerStorage::class)
            ->args([param('profiler.storage.dsn')])

        ->set('profiler_listener', ProfilerListener::class)
            ->args([
                service('profiler'),
                service('request_stack'),
                null,
                
use Symfony\Bridge\Twig\Command\DebugCommand;
use Symfony\Bundle\TwigBundle\Command\LintCommand;

return static function DContainerConfigurator $container) {
    $container->services()
        ->set('twig.command.debug', DebugCommand::class)
            ->args([
                service('twig'),
                param('kernel.project_dir'),
                param('kernel.bundles_metadata'),
                param('twig.default_path'),
                service('debug.file_link_formatter')->nullOnInvalid(),
            ])
            ->tag('console.command')

        ->set('twig.command.lint', LintCommand::class)
            ->args([service('twig')abstract_arg('File name pattern')])
            ->tag('console.command')
    ;
};
// OIDC         ->set('security.access_token_handler.oidc_user_info.http_client', HttpClientInterface::class)
            ->abstract()
            ->factory([service('http_client'), 'withOptions'])
            ->args([abstract_arg('http client options')])

        ->set('security.access_token_handler.oidc_user_info', OidcUserInfoTokenHandler::class)
            ->abstract()
            ->args([
                abstract_arg('http client'),
                service('logger')->nullOnInvalid(),
                abstract_arg('claim'),
            ])

        ->set('security.access_token_handler.oidc', OidcTokenHandler::class)
            ->abstract()
            ->args([
                abstract_arg('signature algorithm'),
                abstract_arg('signature key'),
                abstract_arg('audience'),
                abstract_arg('issuers'),
                'sub',
                
param('security.authentication.session_strategy.strategy'),
                service('security.csrf.token_storage')->ignoreOnInvalid(),
            ])
        ->alias(SessionAuthenticationStrategyInterface::class, 'security.authentication.session_strategy')

        ->set('security.authentication.session_strategy_noop', SessionAuthenticationStrategy::class)
            ->args(['none'])

        ->set('security.user_checker', InMemoryUserChecker::class)

        ->set('security.expression_language', ExpressionLanguage::class)
            ->args([service('cache.security_expression_language')->nullOnInvalid()])

        ->set('security.authentication_utils', AuthenticationUtils::class)
            ->args([service('request_stack')])
        ->alias(AuthenticationUtils::class, 'security.authentication_utils')

        // Authorization related services         ->set('security.access.decision_manager', AccessDecisionManager::class)
            ->args([[]])
        ->alias(AccessDecisionManagerInterface::class, 'security.access.decision_manager')

        ->set('security.role_hierarchy', RoleHierarchy::class)
            
->set('twig.extension.profiler', ProfilerExtension::class)
            ->args([service('twig.profile')service('debug.stopwatch')->ignoreOnInvalid()])

        ->set('twig.profile', Profile::class)

        ->set('data_collector.twig', TwigDataCollector::class)
            ->args([service('twig.profile')service('twig')])
            ->tag('data_collector', ['template' => '@WebProfiler/Collector/twig.html.twig', 'id' => 'twig', 'priority' => 257])

        ->set('twig.extension.trans', TranslationExtension::class)
            ->args([service('translator')->nullOnInvalid()])
            ->tag('twig.extension')

        ->set('twig.extension.assets', AssetExtension::class)
            ->args([service('assets.packages')])

        ->set('twig.extension.code', CodeExtension::class)
            ->args([service('debug.file_link_formatter')->ignoreOnInvalid()param('kernel.project_dir')param('kernel.charset')])
            ->tag('twig.extension')

        ->set('twig.extension.routing', RoutingExtension::class)
            ->args([service('router')])

        
use Symfony\Component\HttpKernel\Debug\ErrorHandlerConfigurator;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener;

return static function DContainerConfigurator $container) {
    $container->parameters()->set('debug.error_handler.throw_at', -1);

    $container->services()
        ->set('debug.error_handler_configurator', ErrorHandlerConfigurator::class)
            ->public()
            ->args([
                service('monolog.logger.php')->nullOnInvalid(),
                null, // Log levels map for enabled error levels                 param('debug.error_handler.throw_at'),
                param('kernel.debug'),
                param('kernel.debug'),
                service('monolog.logger.deprecation')->nullOnInvalid(),
            ])
            ->tag('monolog.logger', ['channel' => 'php'])

        ->set('debug.debug_handlers_listener', DebugHandlersListener::class)
            ->tag('kernel.event_subscriber')

        
$s->set('bar', FooClass::class)
        ->args(['foo', service('foo.baz')new Parameter('foo_bar')])
        ->configurator([service('foo.baz'), 'configure']);

    $s->set('foo_bar', '%foo_class%')
        ->args([service('deprecated_service')])
        ->share(false);

    $s->set('method_call1', 'Bar\FooClass')
        ->file(realpath(__DIR__.'/../includes/foo.php'))
        ->call('setBar', [service('foo')])
        ->call('setBar', [service('foo2')->nullOnInvalid()])
        ->call('setBar', [service('foo3')->ignoreOnInvalid()])
        ->call('setBar', [service('foobaz')->ignoreOnInvalid()])
        ->call('setBar', [expr('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")')]);

    $s->set('foo_with_inline', 'Foo')
        ->call('setBar', [service('inlined')]);

    $s->set('inlined', 'Bar')
        ->property('pub', 'pub')
        ->call('setBaz', [service('baz')])
        ->private();

    
->args([[]])
        ->alias(PasswordHasherFactoryInterface::class, 'security.password_hasher_factory')

        ->set('security.user_password_hasher', UserPasswordHasher::class)
            ->args([service('security.password_hasher_factory')])
        ->alias('security.password_hasher', 'security.user_password_hasher')
        ->alias(UserPasswordHasherInterface::class, 'security.password_hasher')

        ->set('form.listener.password_hasher', PasswordHasherListener::class)
            ->args([
                service('security.password_hasher'),
                service('property_accessor')->nullOnInvalid(),
            ])

        ->set('form.type_extension.form.password_hasher', FormTypePasswordHasherExtension::class)
            ->args([
                service('form.listener.password_hasher'),
            ])
            ->tag('form.type_extension', ['extended-type' => FormType::class])

        ->set('form.type_extension.password.password_hasher', PasswordTypePasswordHasherExtension::class)
            ->args([
                service('form.listener.password_hasher'),
            ])
null,
                null,
            ])

        ->set('security.authenticator.signature_remember_me_handler', SignatureRememberMeHandler::class)
            ->abstract()
            ->args([
                abstract_arg('signature hasher'),
                abstract_arg('user provider'),
                service('request_stack'),
                abstract_arg('options'),
                service('logger')->nullOnInvalid(),
            ])
            ->tag('monolog.logger', ['channel' => 'security'])

        ->set('security.authenticator.persistent_remember_me_handler', PersistentRememberMeHandler::class)
            ->abstract()
            ->args([
                abstract_arg('token provider'),
                abstract_arg('user provider'),
                service('request_stack'),
                abstract_arg('options'),
                service('logger')->nullOnInvalid(),
                
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension;

return static function DContainerConfigurator $container) {
    $container->services()
        ->set('form.type_extension.csrf', FormTypeCsrfExtension::class)
            ->args([
                service('security.csrf.token_manager'),
                param('form.type_extension.csrf.enabled'),
                param('form.type_extension.csrf.field_name'),
                service('translator')->nullOnInvalid(),
                param('validator.translation_domain'),
                service('form.server_params'),
            ])
            ->tag('form.type_extension')
    ;
};
Home | Imprint | This part of the site doesn't use cookies.