1: <?php
2: /**
3: * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4: * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5: *
6: * Licensed under The MIT License
7: * For full copyright and license information, please see the LICENSE.txt
8: * Redistributions of files must retain the above copyright notice.
9: *
10: * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11: * @link https://cakephp.org CakePHP(tm) Project
12: * @since 3.1.0
13: * @license https://opensource.org/licenses/mit-license.php MIT License
14: */
15: namespace Cake\Auth\Storage;
16:
17: /**
18: * Memory based non-persistent storage for authenticated user record.
19: */
20: class MemoryStorage implements StorageInterface
21: {
22:
23: /**
24: * User record.
25: *
26: * @var \ArrayAccess|array|null
27: */
28: protected $_user;
29:
30: /**
31: * Redirect url.
32: *
33: * @var string|null
34: */
35: protected $_redirectUrl;
36:
37: /**
38: * {@inheritDoc}
39: */
40: public function read()
41: {
42: return $this->_user;
43: }
44:
45: /**
46: * {@inheritDoc}
47: */
48: public function write($user)
49: {
50: $this->_user = $user;
51: }
52:
53: /**
54: * {@inheritDoc}
55: */
56: public function delete()
57: {
58: $this->_user = null;
59: }
60:
61: /**
62: * {@inheritDoc}
63: */
64: public function redirectUrl($url = null)
65: {
66: if ($url === null) {
67: return $this->_redirectUrl;
68: }
69:
70: if ($url === false) {
71: $this->_redirectUrl = null;
72:
73: return null;
74: }
75:
76: $this->_redirectUrl = $url;
77: }
78: }
79: