Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 6749
Línea 6... Línea 6...
6
 
6
 
7
use Laminas\Db\Adapter\AdapterInterface;
7
use Laminas\Db\Adapter\AdapterInterface;
8
use Laminas\Log\LoggerInterface;
8
use Laminas\Log\LoggerInterface;
9
use LeadersLinked\Mapper\SessionMapper;
9
use LeadersLinked\Mapper\SessionMapper;
-
 
10
use Laminas\Session\SaveHandler\SaveHandlerInterface;
-
 
11
use SessionHandlerInterface;
Línea 10... Línea 12...
10
use Laminas\Session\SaveHandler\SaveHandlerInterface;
12
 
11
 
13
 
Línea 12... Línea 14...
12
class SessionHandler implements SaveHandlerInterface
14
class SessionHandler implements SaveHandlerInterface
Línea 39... Línea 41...
39
    public function __construct(AdapterInterface $adapter, LoggerInterface $logger, int $session_lifetime)
41
    public function __construct(AdapterInterface $adapter, LoggerInterface $logger, int $session_lifetime)
40
    {
42
    {
41
        $this->sessionMapper = SessionMapper::getInstance($adapter, $logger);
43
        $this->sessionMapper = SessionMapper::getInstance($adapter, $logger);
42
        $this->session_lifetime = $session_lifetime;
44
        $this->session_lifetime = $session_lifetime;
43
    }
45
    }
44
 
46
    
-
 
47
    /**
-
 
48
     * 
-
 
49
     * {@inheritDoc}
-
 
50
     * @see SessionHandlerInterface::close()
-
 
51
     */
45
    public function open ($save_path, $session_name)
52
    public function close() : bool
46
    {
53
    {
47
        $this->session_name = $session_name;
-
 
48
        return true;
54
        return true;
49
    }
55
    }
50
 
56
    
-
 
57
    /**
51
 
58
     * 
-
 
59
     * {@inheritDoc}
-
 
60
     * @see SessionHandlerInterface::destroy()
-
 
61
     */
52
    public function close()
62
    public function destroy(string $id) : bool 
53
    {
63
    {
-
 
64
        $this->sessionMapper->delete($id);
54
        return true;
65
        return true;
55
    }
66
    }
Línea -... Línea 67...
-
 
67
    
-
 
68
    /**
-
 
69
     * 
-
 
70
     * {@inheritDoc}
-
 
71
     * @see SessionHandlerInterface::gc()
-
 
72
     */
-
 
73
    public function gc(int $max_lifetime) : int 
-
 
74
    {
-
 
75
        return $this->sessionMapper->deleteAllExpired($max_lifetime);
56
    
76
    }
-
 
77
    
-
 
78
    /**
-
 
79
     * 
-
 
80
     * {@inheritDoc}
-
 
81
     * @see SessionHandlerInterface::open()
-
 
82
     */
-
 
83
    public function open(string $path, string $name) : bool
-
 
84
    {
-
 
85
        $this->session_name = $name;
-
 
86
        return true;
-
 
87
    }
-
 
88
    
-
 
89
    /**
-
 
90
     * 
-
 
91
     * {@inheritDoc}
-
 
92
     * @see SessionHandlerInterface::read()
57
 
93
     */
58
    public function read($session_id)
94
    public function read(string $id) : string
59
    {
95
    {
60
        $session = $this->sessionMapper->fetchOne($session_id);
96
        $session = $this->sessionMapper->fetchOne($id);
61
        if($session){
97
        if($session && $session->data){
62
            return $session->data;
98
            return base64_decode($session->data);
63
        }else{
99
        }else{
64
            return '';
100
            return '';
65
        }
101
        }
66
    }
102
    }
-
 
103
    
-
 
104
    /**
-
 
105
     * 
-
 
106
     * {@inheritDoc}
-
 
107
     * @see SessionHandlerInterface::write()
67
 
108
     */
68
    public function write($session_id, $session_data)
109
    public function write(string $id, string $data) : bool
-
 
110
    {
-
 
111
        $data = base64_encode($data);
69
    {
112
        
70
        $session = $this->read($session_id);
113
        $session = $this->read($id);
71
        if($session) {
114
        if($session) {
72
            return $this->sessionMapper->update($session_id, $session_data);
115
            return $this->sessionMapper->update($id, $data);
73
        } else {
116
        } else {
74
            return $this->sessionMapper->insert($session_id, $this->session_name, $session_data, $this->session_lifetime);
117
            return $this->sessionMapper->insert($id, $this->session_name, $data, $this->session_lifetime);
75
        }
118
        }
Línea 76... Línea -...
76
    }
-
 
77
    
-
 
78
 
-
 
79
    public function destroy($session_id)
-
 
80
    {
-
 
81
        return $this->sessionMapper->delete($session_id);
-
 
82
    }
-
 
83
    
-
 
84
 
-
 
85
    public function gc($maxlifetime)
-
 
86
    {
119
    }