1 | <?php |
||
45 | class SessionHandler |
||
46 | { |
||
47 | /** |
||
48 | * Session factory |
||
49 | * |
||
50 | * @var SessionFactory |
||
51 | * |
||
52 | * @access protected |
||
53 | */ |
||
54 | protected $sessionFactory; |
||
55 | |||
56 | /** |
||
57 | * Flash messenger factory |
||
58 | * |
||
59 | * @var MessengerFactory |
||
60 | * |
||
61 | * @access protected |
||
62 | */ |
||
63 | protected $messengerFactory; |
||
64 | |||
65 | /** |
||
66 | * Session attribute |
||
67 | * |
||
68 | * @var string |
||
69 | * |
||
70 | * @access protected |
||
71 | */ |
||
72 | protected $sessionAttribute = 'aura/session:session'; |
||
73 | |||
74 | /** |
||
75 | * Messenger attribute |
||
76 | * |
||
77 | * @var string |
||
78 | * |
||
79 | * @access protected |
||
80 | */ |
||
81 | protected $messengerAttribute = 'jnjxp/molniya:messenger'; |
||
82 | |||
83 | /** |
||
84 | * Messenger namespace |
||
85 | * |
||
86 | * @var string |
||
87 | * |
||
88 | * @access protected |
||
89 | */ |
||
90 | protected $messengerNamespace = 'Jnjxp\Molniya'; |
||
91 | |||
92 | /** |
||
93 | * Create a session handler |
||
94 | * |
||
95 | * @param SessionFactory $sessionFactory Session factory |
||
96 | * @param MessengerFactory $messengerFactory Flash messenger factory |
||
97 | * |
||
98 | * @access public |
||
99 | */ |
||
100 | 1 | public function __construct( |
|
107 | |||
108 | /** |
||
109 | * Set session attribute |
||
110 | * |
||
111 | * @param string $attr name of attribute for session |
||
112 | * |
||
113 | * @return $this |
||
114 | * |
||
115 | * @access public |
||
116 | */ |
||
117 | 1 | public function setSessionAttribute($attr) |
|
122 | |||
123 | /** |
||
124 | * Set messenger attribute |
||
125 | * |
||
126 | * @param string $attr name of attribute for messenger |
||
127 | * |
||
128 | * @return $this |
||
129 | * |
||
130 | * @access public |
||
131 | */ |
||
132 | 1 | public function setMessengerAttribute($attr) |
|
137 | |||
138 | /** |
||
139 | * Set messenger namespace |
||
140 | * |
||
141 | * @param string $name namespace for messenger segment |
||
142 | * |
||
143 | * @return $this |
||
144 | * |
||
145 | * @access public |
||
146 | */ |
||
147 | 1 | public function setMessengerNamespace($name) |
|
152 | |||
153 | /** |
||
154 | * Create session and messenger and set them as request attributes |
||
155 | * |
||
156 | * @param Request $request PSR7 Request |
||
157 | * @param Response $response PSR7 Response |
||
158 | * @param callable $next Next callable middleware |
||
159 | * |
||
160 | * @return Response |
||
161 | * |
||
162 | * @access public |
||
163 | */ |
||
164 | 1 | public function __invoke(Request $request, Response $response, callable $next) |
|
193 | } |
||
194 |