1: <?php
2:
3: /*
4: * This file is part of the Symfony package.
5: *
6: * (c) Fabien Potencier <fabien@symfony.com>
7: *
8: * For the full copyright and license information, please view the LICENSE
9: * file that was distributed with this source code.
10: */
11:
12: namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
13:
14: /**
15: * SessionHandler proxy.
16: *
17: * @author Drak <drak@zikula.org>
18: */
19: class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface
20: {
21: /**
22: * @var \SessionHandlerInterface
23: */
24: protected $handler;
25:
26: /**
27: * Constructor.
28: *
29: * @param \SessionHandlerInterface $handler
30: */
31: public function __construct(\SessionHandlerInterface $handler)
32: {
33: $this->handler = $handler;
34: $this->wrapper = ($handler instanceof \SessionHandler);
35: $this->saveHandlerName = $this->wrapper ? ini_get('session.save_handler') : 'user';
36: }
37:
38: // \SessionHandlerInterface
39:
40: /**
41: * {@inheritdoc}
42: */
43: public function open($savePath, $sessionName)
44: {
45: $return = (bool) $this->handler->open($savePath, $sessionName);
46:
47: if (true === $return) {
48: $this->active = true;
49: }
50:
51: return $return;
52: }
53:
54: /**
55: * {@inheritdoc}
56: */
57: public function close()
58: {
59: $this->active = false;
60:
61: return (bool) $this->handler->close();
62: }
63:
64: /**
65: * {@inheritdoc}
66: */
67: public function read($id)
68: {
69: return (string) $this->handler->read($id);
70: }
71:
72: /**
73: * {@inheritdoc}
74: */
75: public function write($id, $data)
76: {
77: return (bool) $this->handler->write($id, $data);
78: }
79:
80: /**
81: * {@inheritdoc}
82: */
83: public function destroy($id)
84: {
85: return (bool) $this->handler->destroy($id);
86: }
87:
88: /**
89: * {@inheritdoc}
90: */
91: public function gc($maxlifetime)
92: {
93: return (bool) $this->handler->gc($maxlifetime);
94: }
95: }
96: