Proyectos de Subversion LeadersLinked - Backend

Rev

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

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