You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

3 years ago
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation\Session;
  11. use Symfony\Component\HttpFoundation\RequestStack;
  12. use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface;
  13. // Help opcache.preload discover always-needed symbols
  14. class_exists(Session::class);
  15. /**
  16. * @author Jérémy Derussé <jeremy@derusse.com>
  17. */
  18. class SessionFactory
  19. {
  20. private $requestStack;
  21. private $storageFactory;
  22. private $usageReporter;
  23. public function __construct(RequestStack $requestStack, SessionStorageFactoryInterface $storageFactory, callable $usageReporter = null)
  24. {
  25. $this->requestStack = $requestStack;
  26. $this->storageFactory = $storageFactory;
  27. $this->usageReporter = $usageReporter;
  28. }
  29. public function createSession(): SessionInterface
  30. {
  31. return new Session($this->storageFactory->createStorage($this->requestStack->getMainRequest()), null, null, $this->usageReporter);
  32. }
  33. }