菜谱项目

SessionHandlerProxy.php 1.8KB

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