Kernel44.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App;
  3. use Nyholm\Psr7\Factory\Psr17Factory;
  4. use Psr\Http\Message\ResponseFactoryInterface;
  5. use Psr\Http\Message\ServerRequestFactoryInterface;
  6. use Psr\Http\Message\StreamFactoryInterface;
  7. use Psr\Http\Message\UploadedFileFactoryInterface;
  8. use Psr\Log\NullLogger;
  9. use Symfony\Bridge\PsrHttpMessage\ArgumentValueResolver\PsrServerRequestResolver;
  10. use Symfony\Bridge\PsrHttpMessage\EventListener\PsrResponseListener;
  11. use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
  12. use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
  13. use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface;
  14. use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
  15. use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Controller\PsrRequestController;
  16. use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
  17. use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
  18. use Symfony\Component\Config\Loader\LoaderInterface;
  19. use Symfony\Component\DependencyInjection\ContainerBuilder;
  20. use Symfony\Component\HttpKernel\Kernel as SymfonyKernel;
  21. use Symfony\Component\Routing\RouteCollectionBuilder;
  22. class Kernel44 extends SymfonyKernel
  23. {
  24. use MicroKernelTrait;
  25. public function registerBundles(): iterable
  26. {
  27. yield new FrameworkBundle();
  28. }
  29. public function getProjectDir(): string
  30. {
  31. return __DIR__;
  32. }
  33. protected function configureRoutes(RouteCollectionBuilder $routes): void
  34. {
  35. $routes->add('/server-request', PsrRequestController::class.'::serverRequestAction')->setMethods(['GET']);
  36. $routes->add('/request', PsrRequestController::class.'::requestAction')->setMethods(['POST']);
  37. $routes->add('/message', PsrRequestController::class.'::messageAction')->setMethods(['PUT']);
  38. }
  39. protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
  40. {
  41. $container->loadFromExtension('framework', [
  42. 'secret' => 'for your eyes only',
  43. 'test' => true,
  44. ]);
  45. $container->register('nyholm.psr_factory', Psr17Factory::class);
  46. $container->setAlias(ResponseFactoryInterface::class, 'nyholm.psr_factory');
  47. $container->setAlias(ServerRequestFactoryInterface::class, 'nyholm.psr_factory');
  48. $container->setAlias(StreamFactoryInterface::class, 'nyholm.psr_factory');
  49. $container->setAlias(UploadedFileFactoryInterface::class, 'nyholm.psr_factory');
  50. $container->register(HttpFoundationFactoryInterface::class, HttpFoundationFactory::class)->setAutowired(true)->setAutoconfigured(true);
  51. $container->register(HttpMessageFactoryInterface::class, PsrHttpFactory::class)->setAutowired(true)->setAutoconfigured(true);
  52. $container->register(PsrResponseListener::class)->setAutowired(true)->setAutoconfigured(true);
  53. $container->register(PsrServerRequestResolver::class)->setAutowired(true)->setAutoconfigured(true);
  54. $container->register('logger', NullLogger::class);
  55. $container->register(PsrRequestController::class)->setPublic(true)->setAutowired(true);
  56. }
  57. }