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.

84 lines
1.8 KiB

3 years ago
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\Session;
  27. use OCP\ISession;
  28. abstract class Session implements \ArrayAccess, ISession {
  29. /**
  30. * @var bool
  31. */
  32. protected $sessionClosed = false;
  33. /**
  34. * $name serves as a namespace for the session keys
  35. *
  36. * @param string $name
  37. */
  38. abstract public function __construct(string $name);
  39. /**
  40. * @param mixed $offset
  41. * @return bool
  42. */
  43. public function offsetExists($offset): bool {
  44. return $this->exists($offset);
  45. }
  46. /**
  47. * @param mixed $offset
  48. * @return mixed
  49. */
  50. public function offsetGet($offset) {
  51. return $this->get($offset);
  52. }
  53. /**
  54. * @param mixed $offset
  55. * @param mixed $value
  56. */
  57. public function offsetSet($offset, $value) {
  58. $this->set($offset, $value);
  59. }
  60. /**
  61. * @param mixed $offset
  62. */
  63. public function offsetUnset($offset) {
  64. $this->remove($offset);
  65. }
  66. /**
  67. * Close the session and release the lock
  68. */
  69. public function close() {
  70. $this->sessionClosed = true;
  71. }
  72. }