1 | <?php |
||
11 | class SubsiteState |
||
12 | { |
||
13 | use Injectable; |
||
14 | |||
15 | /** |
||
16 | * @var int|null |
||
17 | */ |
||
18 | protected $subsiteId; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * @var int|null |
||
23 | */ |
||
24 | protected $originalSubsiteId; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | protected $useSessions; |
||
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, and track the first subsite ID set as the "original". This is used to check |
||
43 | * whether the ID has been changed through a request. |
||
44 | * |
||
45 | * @param int $id |
||
46 | * @return $this |
||
47 | */ |
||
48 | public function setSubsiteId($id) |
||
58 | |||
59 | /** |
||
60 | * Get whether to use sessions for storing the subsite ID |
||
61 | * |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function getUseSessions() |
||
68 | |||
69 | /** |
||
70 | * Set whether to use sessions for storing the subsite ID |
||
71 | * |
||
72 | * @param bool $useSessions |
||
73 | * @return $this |
||
74 | */ |
||
75 | public function setUseSessions($useSessions) |
||
81 | |||
82 | /** |
||
83 | * Get whether the subsite ID has been changed during a request, based on the original and current IDs |
||
84 | * |
||
85 | * @return bool |
||
86 | */ |
||
87 | public function getSubsiteIdWasChanged() |
||
91 | |||
92 | /** |
||
93 | * Perform a given action within the context of a new, isolated state. Modifications are temporary |
||
94 | * and the existing state will be restored afterwards. |
||
95 | * |
||
96 | * @param callable $callback Callback to run. Will be passed the nested state as a parameter |
||
97 | * @return mixed Result of callback |
||
98 | */ |
||
99 | public function withState(callable $callback) |
||
109 | } |
||
110 |