private function loadDoctrineAdapter(array $config, ContainerBuilder $container)
    {
        if ($config['clear']) {
            $definition = new Definition(
                DoctrineTaskExecutionListener::class,
                [new Reference('doctrine.orm.entity_manager', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]
            );
            $definition->addTag(
                'kernel.event_listener',
                ['event' => Events::TASK_AFTER, 'method' => 'clearEntityManagerAfterTask']
            );
            $container->setDefinition('task.adapter.doctrine.execution_listener', $definition);
        }
    }