SessionHandlerProxy.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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\Storage\Proxy;
  11. /**
  12. * SessionHandler proxy.
  13. *
  14. * @author Drak <drak@zikula.org>
  15. */
  16. class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface
  17. {
  18. /**
  19. * @var \SessionHandlerInterface
  20. */
  21. protected $handler;
  22. /**
  23. * Constructor.
  24. *
  25. * @param \SessionHandlerInterface $handler
  26. */
  27. public function __construct(\SessionHandlerInterface $handler)
  28. {
  29. $this->handler = $handler;
  30. $this->wrapper = ($handler instanceof \SessionHandler);
  31. $this->saveHandlerName = $this->wrapper ? ini_get('session.save_handler') : 'user';
  32. }
  33. /**
  34. * @return \SessionHandlerInterface
  35. */
  36. public function getHandler()
  37. {
  38. return $this->handler;
  39. }
  40. // \SessionHandlerInterface
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function open($savePath, $sessionName)
  45. {
  46. return (bool) $this->handler->open($savePath, $sessionName);
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function close()
  52. {
  53. return (bool) $this->handler->close();
  54. }
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public function read($sessionId)
  59. {
  60. return (string) $this->handler->read($sessionId);
  61. }
  62. /**
  63. * {@inheritdoc}
  64. */
  65. public function write($sessionId, $data)
  66. {
  67. return (bool) $this->handler->write($sessionId, $data);
  68. }
  69. /**
  70. * {@inheritdoc}
  71. */
  72. public function destroy($sessionId)
  73. {
  74. return (bool) $this->handler->destroy($sessionId);
  75. }
  76. /**
  77. * {@inheritdoc}
  78. */
  79. public function gc($maxlifetime)
  80. {
  81. return (bool) $this->handler->gc($maxlifetime);
  82. }
  83. }