1 | <?php |
||
12 | class SubsiteState |
||
13 | { |
||
14 | use Injectable; |
||
15 | |||
16 | /** |
||
17 | * @var int|null |
||
18 | */ |
||
19 | protected $subsiteId; |
||
20 | |||
21 | /** |
||
22 | * @var bool |
||
23 | */ |
||
24 | protected $useSessions; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | protected $sessionWasChanged = false; |
||
30 | |||
31 | /** |
||
32 | * Get the current subsite ID |
||
33 | * |
||
34 | * @return int|null |
||
35 | */ |
||
36 | public function getSubsiteId() |
||
40 | |||
41 | /** |
||
42 | * Set the current subsite ID |
||
43 | * |
||
44 | * @param int $id |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function setSubsiteId($id) |
||
53 | |||
54 | /** |
||
55 | * Get whether to use sessions for storing the subsite ID |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function getUseSessions() |
||
63 | |||
64 | /** |
||
65 | * Set whether to use sessions for storing the subsite ID |
||
66 | * |
||
67 | * @param bool $useSessions |
||
68 | * @return $this |
||
69 | */ |
||
70 | public function setUseSessions($useSessions) |
||
76 | |||
77 | public function getSessionWasChanged() |
||
81 | |||
82 | public function setSessionWasChanged($changed = true) |
||
88 | |||
89 | /** |
||
90 | * Perform a given action within the context of a new, isolated state. Modifications are temporary |
||
91 | * and the existing state will be restored afterwards. |
||
92 | * |
||
93 | * @param callable $callback Callback to run. Will be passed the nested state as a parameter |
||
94 | * @return mixed Result of callback |
||
95 | */ |
||
96 | public function withState(callable $callback) |
||
106 | } |
||
107 |