1 | <?php |
||
13 | abstract class WPInv_Session { |
||
14 | |||
15 | /** |
||
16 | * Customer ID. |
||
17 | * |
||
18 | * @var int $_customer_id Customer ID. |
||
19 | */ |
||
20 | protected $_customer_id; |
||
21 | |||
22 | /** |
||
23 | * Session Data. |
||
24 | * |
||
25 | * @var array $_data Data array. |
||
26 | */ |
||
27 | protected $_data = array(); |
||
28 | |||
29 | /** |
||
30 | * Dirty when the session needs saving. |
||
31 | * |
||
32 | * @var bool $_dirty When something changes |
||
33 | */ |
||
34 | protected $_dirty = false; |
||
35 | |||
36 | /** |
||
37 | * Init hooks and session data. Extended by child classes. |
||
38 | * |
||
39 | * @since 3.3.0 |
||
40 | */ |
||
41 | public function init() {} |
||
42 | |||
43 | /** |
||
44 | * Cleanup session data. Extended by child classes. |
||
45 | */ |
||
46 | public function cleanup_sessions() {} |
||
47 | |||
48 | /** |
||
49 | * Magic get method. |
||
50 | * |
||
51 | * @param mixed $key Key to get. |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function __get( $key ) { |
||
57 | |||
58 | /** |
||
59 | * Magic set method. |
||
60 | * |
||
61 | * @param mixed $key Key to set. |
||
62 | * @param mixed $value Value to set. |
||
63 | */ |
||
64 | public function __set( $key, $value ) { |
||
67 | |||
68 | /** |
||
69 | * Magic isset method. |
||
70 | * |
||
71 | * @param mixed $key Key to check. |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function __isset( $key ) { |
||
77 | |||
78 | /** |
||
79 | * Magic unset method. |
||
80 | * |
||
81 | * @param mixed $key Key to unset. |
||
82 | */ |
||
83 | public function __unset( $key ) { |
||
89 | |||
90 | /** |
||
91 | * Get a session variable. |
||
92 | * |
||
93 | * @param string $key Key to get. |
||
94 | * @param mixed $default used if the session variable isn't set. |
||
95 | * @return array|string value of session variable |
||
96 | */ |
||
97 | public function get( $key, $default = null ) { |
||
101 | |||
102 | /** |
||
103 | * Set a session variable. |
||
104 | * |
||
105 | * @param string $key Key to set. |
||
106 | * @param mixed $value Value to set. |
||
107 | */ |
||
108 | public function set( $key, $value ) { |
||
114 | |||
115 | /** |
||
116 | * Get customer ID. |
||
117 | * |
||
118 | * @return int |
||
119 | */ |
||
120 | public function get_customer_id() { |
||
123 | } |
||
124 |